CmdID / aws / aws imagebuilder
aws imagebuilder put-image-policy
Applies a policy to an image. AWS CLI reference
1 example 2 options Its page in the AWS CLI reference
Examples
To apply a resource policy to an image
The following put-image-policy example applies a resource policy to an image to enable cross-account sharing of images. We recommend you use the RAM CLI command create-resource-share. If you use the EC2 Image Builder CLI command put-image-policy, you must also use the RAM CLI command promote-resource-share-create-from-policy in order for the resource to be visible to all principals with whom the resource is shared.
aws imagebuilder put-image-policy --image-arn arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1 --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImage", "imagebuilder:ListImages" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1" ] } ] }'Identify--image-arnThe Amazon Resource Name (ARN) of the image that this policy should be applied to.--policyThe resource policy to apply to the image, as a JSON policy document.Its output
{
"requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"imageArn": "arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1"
}For more information, see Manage custom image creation in Image Builder through a repeatable pipeline process in the EC2 Image Builder Users Guide.
Options
--image-arnThe Amazon Resource Name (ARN) of the image that this policy should be applied to.--policyThe resource policy to apply to the image, as a JSON policy document.