ImageRecipe
- class aws_cdk.aws_imagebuilder_alpha.ImageRecipe(scope, id, *, base_image, ami_tags=None, block_devices=None, components=None, description=None, image_recipe_name=None, image_recipe_version=None, tags=None, uninstall_ssm_agent_after_build=None, user_data_override=None, working_directory=None)
Bases:
Resource(experimental) Represents an EC2 Image Builder Image Recipe.
- See:
https://docs.aws.amazon.com/imagebuilder/latest/userguide/manage-recipes.html
- Stability:
experimental
- ExampleMetadata:
infused
Example:
parameterized_component = imagebuilder.Component.from_component_name(self, "ParameterizedComponent", "my-parameterized-component") image_recipe = imagebuilder.ImageRecipe(self, "ParameterizedImageRecipe", base_image=imagebuilder.BaseImage.from_ssm_parameter_name("/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64"), components=[imagebuilder.ComponentConfiguration( component=parameterized_component, parameters={ "environment": imagebuilder.ComponentParameterValue.from_string("production"), "version": imagebuilder.ComponentParameterValue.from_string("1.0.0") } ) ] )
- Parameters:
scope (
Construct)id (
str)base_image (
BaseImage) – (experimental) The base image for customizations specified in the image recipe.ami_tags (
Optional[Mapping[str,str]]) – (experimental) The additional tags to assign to the output AMI generated by the build. Default: Noneblock_devices (
Optional[Sequence[Union[BlockDevice,Dict[str,Any]]]]) – (experimental) The block devices to attach to the instance used for building the image. Default: Nonecomponents (
Optional[Sequence[Union[ComponentConfiguration,Dict[str,Any]]]]) – (experimental) The list of component configurations to apply in the image build. Default: Nonedescription (
Optional[str]) – (experimental) The description of the image recipe. Default: Noneimage_recipe_name (
Optional[str]) – (experimental) The name of the image recipe. Default: - a name is generatedimage_recipe_version (
Optional[str]) – (experimental) The version of the image recipe. Default: 1.0.xtags (
Optional[Mapping[str,str]]) – (experimental) The tags to apply to the image recipe. Default: Noneuninstall_ssm_agent_after_build (
Optional[bool]) – (experimental) Whether to uninstall the Systems Manager agent from your final build image, prior to creating the new AMI. Default: - this is false if the Systems Manager agent is pre-installed on the base image. Otherwise, this is true.user_data_override (
Optional[UserData]) – (experimental) The user data commands to pass to Image Builder build and test EC2 instances. For Linux and macOS, Image Builder uses a default user data script to install the Systems Manager agent. If you override the user data, you must ensure to add commands to install Systems Manager agent, if it is not pre-installed on your base image. Default: Noneworking_directory (
Optional[str]) – (experimental) The working directory for use during build and test workflows. Default: - the Image Builder default working directory is used. For Linux and macOS builds, this would be /tmp. For Windows builds, this would be C:/
- Stability:
experimental
Methods
- add_block_device(*block_devices)
(experimental) Adds block devices to attach to the instance used for building the image.
- Parameters:
block_devices (
BlockDevice) – The list of block devices to attach.- Stability:
experimental
- Return type:
None
- 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 recipe.
- Parameters:
grantee (
IGrantable) – The principal.actions (
str) – The list of actions.
- Stability:
experimental
- Return type:
- grant_read(grantee)
(experimental) Grant read permissions to the given grantee for the image recipe.
- Parameters:
grantee (
IGrantable) – The principal.- 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.ImageRecipe'
- 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.
- image_recipe_arn
(experimental) The ARN of the image recipe.
- Stability:
experimental
- image_recipe_name
(experimental) The name of the image recipe.
- Stability:
experimental
- image_recipe_version
(experimental) The version of the image recipe.
- Stability:
experimental
- node
The tree node.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_image_recipe_arn(scope, id, image_recipe_arn)
(experimental) Import an existing image recipe given its ARN.
- Parameters:
scope (
Construct)id (
str)image_recipe_arn (
str)
- Stability:
experimental
- Return type:
- classmethod from_image_recipe_attributes(scope, id, *, image_recipe_arn=None, image_recipe_name=None, image_recipe_version=None)
(experimental) Import an existing image recipe by providing its attributes.
If the image recipe 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_recipe_arn (
Optional[str]) – (experimental) The ARN of the image recipe. Default: - derived from the imageRecipeNameimage_recipe_name (
Optional[str]) – (experimental) The name of the image recipe. Default: - derived from the imageRecipeArnimage_recipe_version (
Optional[str]) – (experimental) The version of the image recipe. Default: - derived from imageRecipeArn. if a imageRecipeName is provided, the latest version, x.x.x, will be used
- Stability:
experimental
- Return type:
- classmethod from_image_recipe_name(scope, id, image_recipe_name)
(experimental) Import the latest version of an existing image recipe given its name.
The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
- Parameters:
scope (
Construct)id (
str)image_recipe_name (
str)
- Stability:
experimental
- Return type:
- 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_recipe(x)
(experimental) Return whether the given object is an ImageRecipe.
- 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