putComponentPolicy
abstract suspend fun putComponentPolicy(input: PutComponentPolicyRequest): PutComponentPolicyResponse
Applies a policy to a component. The preferred way to share resources is with the RAM API CreateResourceShare. If you use the PutComponentPolicy operation instead, you must also call the RAM API PromoteResourceShareCreatedFromPolicy. Otherwise, the resource isn't visible to the principals that it's shared with.
Samples
// The following example applies a resource policy that grants another account permission to get and
// list the component.
val resp = imagebuilderClient.putComponentPolicy {
componentArn = "arn:aws:imagebuilder:us-west-2:111122223333:component/my-shared-component/1.0.0/1"
policy = "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Effect\": \"Allow\", \"Principal\": {\"AWS\": \"arn:aws:iam::444455556666:root\"}, \"Action\": [\"imagebuilder:GetComponent\", \"imagebuilder:ListComponents\"], \"Resource\": [\"arn:aws:imagebuilder:us-west-2:111122223333:component/my-shared-component/1.0.0/1\"]}]}"
}Content copied to clipboard