ContainerRecipe

class aws_cdk.aws_imagebuilder_alpha.ContainerRecipe(scope, id, *, base_image, target_repository, components=None, container_recipe_name=None, container_recipe_version=None, description=None, dockerfile=None, instance_block_devices=None, instance_image=None, kms_key=None, os_version=None, tags=None, working_directory=None)

Bases: ContainerRecipeBase

(experimental) Represents an EC2 Image Builder Container Recipe.

See:

https://docs.aws.amazon.com/imagebuilder/latest/userguide/manage-recipes.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_pipeline = imagebuilder.ImagePipeline(self, "MyContainerPipeline",
    recipe=example_container_recipe
)
Parameters:
  • scope (Construct)

  • id (str)

  • base_image (BaseContainerImage) – (experimental) The base image for customizations specified in the container recipe.

  • target_repository (Repository) – (experimental) The container repository where the output container image is stored.

  • components (Optional[Sequence[Union[ComponentConfiguration, Dict[str, Any]]]]) – (experimental) The list of component configurations to apply in the image build. Default: None

  • container_recipe_name (Optional[str]) – (experimental) The name of the container recipe. Default: a name is generated

  • container_recipe_version (Optional[str]) – (experimental) The version of the container recipe. Default: 1.0.x

  • description (Optional[str]) – (experimental) The description of the container recipe. Default: None

  • dockerfile (Optional[DockerfileData]) – (experimental) The dockerfile template used to build the container image. Default: - a standard dockerfile template will be generated to pull the base image, perform environment setup, and run all components in the recipe

  • instance_block_devices (Optional[Sequence[Union[BlockDevice, Dict[str, Any]]]]) – (experimental) The block devices to attach to the instance used for building, testing, and distributing the container image. Default: the block devices of the instance image will be used

  • instance_image (Optional[ContainerInstanceImage]) – (experimental) The image to use to launch the instance used for building, testing, and distributing the container image. Default: Image Builder will use the appropriate ECS-optimized AMI

  • kms_key (Optional[IKey]) – (experimental) The KMS key used to encrypt the dockerfile template. Default: None

  • os_version (Optional[OSVersion]) – (experimental) The operating system (OS) version of the base image. Default: - Image Builder will determine the OS version of the base image, if sourced from a third-party container registry. Otherwise, the OS version of the base image is required.

  • tags (Optional[Mapping[str, str]]) – (experimental) The tags to apply to the container recipe. Default: None

  • working_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_instance_block_device(*instance_block_devices)

(experimental) Adds block devices to attach to the instance used for building, testing, and distributing the container image.

Parameters:

instance_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 container recipe.

Parameters:
  • grantee (IGrantable) – The principal.

  • actions (str) – The list of actions.

Stability:

experimental

Return type:

Grant

grant_read(grantee)

(experimental) Grant read permissions to the given grantee for the container recipe.

Parameters:

grantee (IGrantable) – The principal.

Stability:

experimental

Return type:

Grant

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

PROPERTY_INJECTION_ID = '@aws-cdk.aws-imagebuilder-alpha.ContainerRecipe'
container_recipe_arn

(experimental) The ARN of the container recipe.

Stability:

experimental

container_recipe_name

(experimental) The name of the container recipe.

Stability:

experimental

container_recipe_version

(experimental) The version of the container recipe.

Stability:

experimental

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.

node

The tree node.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_container_recipe_arn(scope, id, container_recipe_arn)

(experimental) Import an existing container recipe given its ARN.

Parameters:
  • scope (Construct)

  • id (str)

  • container_recipe_arn (str)

Stability:

experimental

Return type:

IContainerRecipe

classmethod from_container_recipe_attributes(scope, id, *, container_recipe_arn=None, container_recipe_name=None, container_recipe_version=None)

(experimental) Import an existing container recipe by providing its attributes.

If the container 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)

  • container_recipe_arn (Optional[str]) – (experimental) The ARN of the container recipe. Default: - derived from containerRecipeName

  • container_recipe_name (Optional[str]) – (experimental) The name of the container recipe. Default: - derived from containerRecipeArn

  • container_recipe_version (Optional[str]) – (experimental) The version of the container recipe. Default: - derived from containerRecipeArn. if a containerRecipeName is provided, the latest version, x.x.x, will be used.

Stability:

experimental

Return type:

IContainerRecipe

classmethod from_container_recipe_name(scope, id, container_recipe_name)

(experimental) Import the latest version of an existing container 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)

  • container_recipe_name (str)

Stability:

experimental

Return type:

IContainerRecipe

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_container_recipe(x)

(experimental) Return whether the given object is a ContainerRecipe.

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