class ImageRecipe (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ImageBuilder.Alpha.ImageRecipe |
Go | github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2#ImageRecipe |
Java | software.amazon.awscdk.services.imagebuilder.alpha.ImageRecipe |
Python | aws_cdk.aws_imagebuilder_alpha.ImageRecipe |
TypeScript (source) | @aws-cdk/aws-imagebuilder-alpha ยป ImageRecipe |
Implements
IConstruct, IDependable, IResource, IEnvironment, IImage, IRecipe
Represents an EC2 Image Builder Image Recipe.
See also: https://docs.aws.amazon.com/imagebuilder/latest/userguide/manage-recipes.html
Example
const parameterizedComponent = imagebuilder.Component.fromComponentName(
this,
'ParameterizedComponent',
'my-parameterized-component'
);
const imageRecipe = new imagebuilder.ImageRecipe(this, 'ParameterizedImageRecipe', {
baseImage: imagebuilder.BaseImage.fromSsmParameterName(
'/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
),
components: [
{
component: parameterizedComponent,
parameters: {
environment: imagebuilder.ComponentParameterValue.fromString('production'),
version: imagebuilder.ComponentParameterValue.fromString('1.0.0')
}
}
]
});
Initializer
new ImageRecipe(scope: Construct, id: string, props: ImageRecipeProps)
Parameters
- scope
Construct - id
string - props
ImageRecipe Props
Construct Props
| Name | Type | Description |
|---|---|---|
| base | Base | The base image for customizations specified in the image recipe. |
| ami | { [string]: string } | The additional tags to assign to the output AMI generated by the build. |
| block | Block[] | The block devices to attach to the instance used for building the image. |
| components? | Component[] | The list of component configurations to apply in the image build. |
| description? | string | The description of the image recipe. |
| image | string | The name of the image recipe. |
| image | string | The version of the image recipe. |
| tags? | { [string]: string } | The tags to apply to the image recipe. |
| uninstall | boolean | Whether to uninstall the Systems Manager agent from your final build image, prior to creating the new AMI. |
| user | User | The user data commands to pass to Image Builder build and test EC2 instances. |
| working | string | The working directory for use during build and test workflows. |
baseImage
Type:
Base
The base image for customizations specified in the image recipe.
amiTags?
Type:
{ [string]: string }
(optional, default: None)
The additional tags to assign to the output AMI generated by the build.
blockDevices?
Type:
Block[]
(optional, default: None)
The block devices to attach to the instance used for building the image.
components?
Type:
Component[]
(optional, default: None)
The list of component configurations to apply in the image build.
description?
Type:
string
(optional, default: None)
The description of the image recipe.
imageRecipeName?
Type:
string
(optional, default: a name is generated)
The name of the image recipe.
imageRecipeVersion?
Type:
string
(optional, default: 1.0.x)
The version of the image recipe.
tags?
Type:
{ [string]: string }
(optional, default: None)
The tags to apply to the image recipe.
uninstallSsmAgentAfterBuild?
Type:
boolean
(optional, default: this is false if the Systems Manager agent is pre-installed on the base image. Otherwise, this is true.)
Whether to uninstall the Systems Manager agent from your final build image, prior to creating the new AMI.
userDataOverride?
Type:
User
(optional, default: None)
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.
workingDirectory?
Type:
string
(optional, 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:/)
The working directory for use during build and test workflows.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| image | string | The ARN of the image recipe. |
| image | string | The name of the image recipe. |
| image | string | The version of the image recipe. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
Type:
Resource
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.
imageRecipeArn
Type:
string
The ARN of the image recipe.
imageRecipeName
Type:
string
The name of the image recipe.
imageRecipeVersion
Type:
string
The version of the image recipe.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| add | Adds block devices to attach to the instance used for building the image. |
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grant custom actions to the given grantee for the image recipe. |
| grant | Grant read permissions to the given grantee for the image recipe. |
| to | Returns a string representation of this construct. |
| static from | Import an existing image recipe given its ARN. |
| static from | Import an existing image recipe by providing its attributes. |
| static from | Import the latest version of an existing image recipe given its name. |
| static is | Return whether the given object is an ImageRecipe. |
addBlockDevice(...blockDevices)
public addBlockDevice(...blockDevices: BlockDevice[]): void
Parameters
- blockDevices
Blockโ The list of block devices to attach.Device
Adds block devices to attach to the instance used for building the image.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
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).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantableโ The principal. - actions
stringโ The list of actions.
Returns
Grant custom actions to the given grantee for the image recipe.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal.
Returns
Grant read permissions to the given grantee for the image recipe.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromImageRecipeArn(scope, id, imageRecipeArn)
public static fromImageRecipeArn(scope: Construct, id: string, imageRecipeArn: string): IImageRecipe
Parameters
- scope
Construct - id
string - imageRecipeArn
string
Returns
Import an existing image recipe given its ARN.
static fromImageRecipeAttributes(scope, id, attrs)
public static fromImageRecipeAttributes(scope: Construct, id: string, attrs: ImageRecipeAttributes): IImageRecipe
Parameters
- scope
Construct - id
string - attrs
ImageRecipe Attributes
Returns
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.
static fromImageRecipeName(scope, id, imageRecipeName)
public static fromImageRecipeName(scope: Construct, id: string, imageRecipeName: string): IImageRecipe
Parameters
- scope
Construct - id
string - imageRecipeName
string
Returns
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.
static isImageRecipe(x)
public static isImageRecipe(x: any): boolean
Parameters
- x
any
Returns
boolean
Return whether the given object is an ImageRecipe.

.NET
Go
Java
Python
TypeScript (