AWS::ImageBuilder::ContainerRecipe - AWS CloudFormation

AWS::ImageBuilder::ContainerRecipe

Creates a new container recipe. Container recipes define how images are configured, tested, and assessed.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::ImageBuilder::ContainerRecipe", "Properties" : { "Components" : [ ComponentConfiguration, ... ], "ContainerType" : String, "Description" : String, "DockerfileTemplateData" : String, "DockerfileTemplateUri" : String, "ImageOsVersionOverride" : String, "InstanceConfiguration" : InstanceConfiguration, "KmsKeyId" : String, "Name" : String, "ParentImage" : String, "PlatformOverride" : String, "Tags" : {Key : Value, ...}, "TargetRepository" : TargetContainerRepository, "Version" : String, "WorkingDirectory" : String } }

YAML

Type: AWS::ImageBuilder::ContainerRecipe Properties: Components: - ComponentConfiguration ContainerType: String Description: String DockerfileTemplateData: String DockerfileTemplateUri: String ImageOsVersionOverride: String InstanceConfiguration: InstanceConfiguration KmsKeyId: String Name: String ParentImage: String PlatformOverride: String Tags: Key : Value TargetRepository: TargetContainerRepository Version: String WorkingDirectory: String

Properties

Components

Components for build and test that are included in the container recipe.

Required: Yes

Type: List of ComponentConfiguration

Update requires: Replacement

ContainerType

Specifies the type of container, such as Docker.

Required: Yes

Type: String

Allowed values: DOCKER

Update requires: Replacement

Description

The description of the container recipe.

Required: No

Type: String

Minimum: 1

Maximum: 1024

Update requires: Replacement

DockerfileTemplateData

Dockerfiles are text documents that are used to build Docker containers, and ensure that they contain all of the elements required by the application running inside. The template data consists of contextual variables where Image Builder places build information or scripts, based on your container image recipe.

Required: No

Type: String

Update requires: Replacement

DockerfileTemplateUri

The S3 URI for the Dockerfile that will be used to build your container image.

Required: No

Type: String

Update requires: Replacement

ImageOsVersionOverride

Specifies the operating system version for the source image.

Required: No

Type: String

Update requires: Replacement

InstanceConfiguration

A group of options that can be used to configure an instance for building and testing container images.

Required: No

Type: InstanceConfiguration

Update requires: Replacement

KmsKeyId

Identifies which KMS key is used to encrypt the container image for distribution to the target Region.

Required: No

Type: String

Minimum: 1

Maximum: 1024

Update requires: Replacement

Name

The name of the container recipe.

Required: Yes

Type: String

Pattern: ^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$

Update requires: Replacement

ParentImage

The base image for the container recipe.

Required: Yes

Type: String

Minimum: 1

Maximum: 1024

Update requires: Replacement

PlatformOverride

Specifies the operating system platform when you use a custom source image.

Required: No

Type: String

Update requires: Replacement

Tags

Tags that are attached to the container recipe.

Required: No

Type: Map of String

Update requires: Replacement

TargetRepository

The destination repository for the container image.

Required: Yes

Type: TargetContainerRepository

Update requires: Replacement

Version

The semantic version of the container recipe.

Note

The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can assign values for the first three, and can filter on all of them.

Assignment: For the first three nodes you can assign any positive integer value, including zero, with an upper limit of 2^30-1, or 1073741823 for each node. Image Builder automatically assigns the build number to the fourth node.

Patterns: You can use any numeric pattern that adheres to the assignment requirements for the nodes that you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a date, such as 2021.01.01.

Filtering: With semantic versioning, you have the flexibility to use wildcards (x) to specify the most recent versions or nodes when selecting the base image or components for your recipe. When you use a wildcard in any node, all nodes to the right of the first wildcard must also be wildcards.

Required: Yes

Type: String

Pattern: ^[0-9]+\.[0-9]+\.[0-9]+$

Update requires: Replacement

WorkingDirectory

The working directory for use during build and test workflows.

Required: No

Type: String

Minimum: 1

Maximum: 1024

Update requires: Replacement

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource ARN, such as arn:aws:imagebuilder:us-east-1:123456789012:container-recipe/mybasicrecipe/2020.12.17.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Arn

Returns the Amazon Resource Name (ARN) of the container recipe. For example, arn:aws:imagebuilder:us-east-1:123456789012:container-recipe/mybasicrecipe/2020.12.17.

Name

Returns the name of the container recipe.

Examples

Create a container recipe.

The following example shows the schema for the ContainerRecipe resource document in both YAML and JSON format.

YAML

Resources: ContainerRecipeAllParameters: Type: 'AWS::ImageBuilder::ContainerRecipe' Properties: Name: 'container-recipe-name' Version: '1.0.0' ParentImage: !Ref ParentImage Description: 'description' ContainerType: 'DOCKER' Components: - ComponentArn: !Ref ComponentArn - ComponentArn: !Ref AnotherComponentArn TargetRepository: Service: 'ECR' RepositoryName: !Ref RepositoryName DockerfileTemplateData: | FROM {{{ imagebuilder:parentImage }}} {{{ imagebuilder:environments }}} {{{ imagebuilder:components }}} WorkingDirectory: "dummy-working-directory" KmsKeyId: !Ref KmsKeyId Tags: Usage: 'Documentation' Outputs: OutputContainerRecipeArn: Value: 'Fn::GetAtt': - ContainerRecipeAllParameters - Arn

JSON

{ "Resources": { "ContainerRecipeAllParameters": { "Type": "AWS::ImageBuilder::ContainerRecipe", "Properties": { "Name": "container-recipe-name", "Version": "1.0.0", "ParentImage": { "Ref": "ParentImage" }, "Description": "description", "ContainerType": "DOCKER", "Components": [ { "ComponentArn": { "Ref": "ComponentArn" } }, { "ComponentArn": { "Ref": "AnotherComponentArn" } } ], "TargetRepository": { "Service": "ECR", "RepositoryName": { "Ref": "RepositoryName" }, }, "DockerfileTemplateData": "FROM {{{ imagebuilder:parentImage }}}\n{{{ imagebuilder:environments }}}\n{{{ imagebuilder:components }}}\n", "WorkingDirectory": "dummy-working-directory", "KmsKeyId": { "Ref": "KmsKeyId" }, "Tags": { "Usage": "Documentation" } } } }, "Outputs": { "OutputContainerRecipeArn": { "Value": { "Fn::GetAtt": [ "ContainerRecipeAllParameters", "Arn" ] } } } }