Image
- class aws_cdk.aws_imagebuilder_alpha.Image(scope, id, *, recipe, deletion_execution_role=None, distribution_configuration=None, enhanced_image_metadata_enabled=None, execution_role=None, image_scanning_ecr_repository=None, image_scanning_ecr_tags=None, image_scanning_enabled=None, image_tests_enabled=None, infrastructure_configuration=None, log_group=None, tags=None, workflows=None)
Bases:
Resource(experimental) Represents an EC2 Image Builder Image.
- See:
https://docs.aws.amazon.com/imagebuilder/latest/userguide/create-images.html
- Stability:
experimental
- ExampleMetadata:
infused
Example:
container_recipe = imagebuilder.ContainerRecipe(self, "MyContainerRecipe", base_image=imagebuilder.BaseContainerImage.from_docker_hub("amazonlinux", "latest"), target_repository=imagebuilder.Repository.from_ecr( ecr.Repository.from_repository_name(self, "Repository", "my-container-repo")) ) container_image = imagebuilder.Image(self, "MyContainerImage", recipe=container_recipe )
- Parameters:
scope (
Construct)id (
str)recipe (
IRecipeBase) – (experimental) The recipe that defines the base image, components, and customizations used to build the image. This can either be an image recipe, or a container recipe.deletion_execution_role (
Optional[IRole]) – (experimental) The execution role to use for deleting the image as well as the underlying resources, such as the AMIs, snapshots, and containers. This role should contain resource lifecycle permissions required to delete the underlying AMIs/containers. Default: - no execution role. Only the Image Builder image will be deleted.distribution_configuration (
Optional[IDistributionConfiguration]) – (experimental) The distribution configuration used for distributing the image. Default: Noneenhanced_image_metadata_enabled (
Optional[bool]) – (experimental) If enabled, collects additional information about the image being created, including the operating system (OS) version and package list for the AMI. Default: trueexecution_role (
Optional[IRole]) – (experimental) The execution role used to perform workflow actions to build the image. By default, the Image Builder Service Linked Role (SLR) will be created automatically and used as the execution role. However, when providing a custom set of image workflows for the image, an execution role will be generated with the minimal permissions needed to execute the workflows. Default: - Image Builder will use the SLR if possible. Otherwise, an execution role will be generatedimage_scanning_ecr_repository (
Optional[IRepository]) – (experimental) The container repository that Amazon Inspector scans to identify findings for your container images. If a repository is not provided, Image Builder creates a repository namedimage-builder-image-scanning-repositoryfor vulnerability scanning. Default: - if scanning is enabled, a repository will be created by Image Builder if one is not providedimage_scanning_ecr_tags (
Optional[Sequence[str]]) – (experimental) The tags for Image Builder to apply to the output container image that Amazon Inspector scans. Default: Noneimage_scanning_enabled (
Optional[bool]) – (experimental) Indicates whether Image Builder keeps a snapshot of the vulnerability scans that Amazon Inspector runs against the build instance when you create a new image. Default: falseimage_tests_enabled (
Optional[bool]) – (experimental) Whether to run tests after building an image. Default: trueinfrastructure_configuration (
Optional[IInfrastructureConfiguration]) – (experimental) The infrastructure configuration used for building the image. A default infrastructure configuration will be used if one is not provided. The default configuration will create an instance profile and role with minimal permissions needed to build the image, attached to the EC2 instance. IMDSv2 will be required by default on the instances used to build and test the image. Default: - an infrastructure configuration will be created with the default settingslog_group (
Optional[ILogGroup]) – (experimental) The log group to use for the image. By default, a log group will be created with the format/aws/imagebuilder/<image-name>Default: - a log group will be createdtags (
Optional[Mapping[str,str]]) – (experimental) The tags to apply to the image. Default: Noneworkflows (
Optional[Sequence[Union[WorkflowConfiguration,Dict[str,Any]]]]) – (experimental) The list of workflow configurations used to build the image. Default: - Image Builder will use a default set of workflows for the build to build, test, and distribute the image
- Stability:
experimental
Methods
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).- Parameters:
policy (
RemovalPolicy)- Return type:
None
- grant(grantee, *actions)
(experimental) Grant custom actions to the given grantee for the image.
- Parameters:
grantee (
IGrantable) – The principal.actions (
str) – The list of actions.
- Stability:
experimental
- Return type:
- grant_default_execution_role_permissions(grantee)
(experimental) Grants the default permissions for building an image to the provided execution role.
- Parameters:
grantee (
IGrantable) – The execution role used for the image build.- Stability:
experimental
- Return type:
List[Grant]
- grant_read(grantee)
(experimental) Grant read permissions to the given grantee for the image.
- Parameters:
grantee (
IGrantable) – The principal.- Stability:
experimental
- Return type:
- to_base_image()
(experimental) Converts the image to a BaseImage, to use as the parent image in an image recipe.
- Stability:
experimental
- Return type:
- to_container_base_image()
(experimental) Converts the image to a ContainerBaseImage, to use as the parent image in a container recipe.
- Stability:
experimental
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- PROPERTY_INJECTION_ID = '@aws-cdk.aws-imagebuilder-alpha.Image'
- env
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by creating new class instances like
new Role(),new Bucket(), etc.), this is always the same as the environment of the stack they belong to.For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(),Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
- execution_role
(experimental) The execution role used for the image build.
- Stability:
experimental
- image_arn
(experimental) The ARN of the image.
- Stability:
experimental
- image_id
(experimental) The AMI ID of the EC2 AMI, or URI for the container.
- Stability:
experimental
- Attribute:
true
- image_name
(experimental) The name of the image.
- Stability:
experimental
- image_version
(experimental) The version of the image.
- Stability:
experimental
- infrastructure_configuration
(experimental) The infrastructure configuration used for the image build.
- Stability:
experimental
- node
The tree node.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_image_arn(scope, id, image_arn)
(experimental) Import an existing image given its ARN.
- classmethod from_image_attributes(scope, id, *, image_arn=None, image_name=None, image_version=None)
(experimental) Import an existing image by providing its attributes.
If the image name is provided as an attribute, it must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
- Parameters:
scope (
Construct)id (
str)image_arn (
Optional[str]) – (experimental) The ARN of the image. Default: - derived from the imageNameimage_name (
Optional[str]) – (experimental) The name of the image. Default: - derived from the imageArnimage_version (
Optional[str]) – (experimental) The version of the image. Default: - the latest version of the image, x.x.x
- Stability:
experimental
- Return type:
- classmethod from_image_name(scope, id, image_name)
(experimental) Import an existing image given its name.
The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.
- classmethod is_image(x)
(experimental) Return whether the given object is an Image.
- Parameters:
x (
Any)- Stability:
experimental
- Return type:
bool
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct)- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct)- Return type:
bool