Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
ImageRecipe L2 construct
Represents an EC2 Image Builder Image Recipe.
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')
}
}
]
});
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")
}
)
]
)
IComponent parameterizedComponent = Component.fromComponentName(this, "ParameterizedComponent", "my-parameterized-component");
ImageRecipe imageRecipe = ImageRecipe.Builder.create(this, "ParameterizedImageRecipe")
.baseImage(BaseImage.fromSsmParameterName("/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64"))
.components(List.of(ComponentConfiguration.builder()
.component(parameterizedComponent)
.parameters(Map.of(
"environment", ComponentParameterValue.fromString("production"),
"version", ComponentParameterValue.fromString("1.0.0")))
.build()))
.build();
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var parameterizedComponent = Component.FromComponentName(this, "ParameterizedComponent", "my-parameterized-component");
var imageRecipe = new ImageRecipe(this, "ParameterizedImageRecipe", new ImageRecipeProps {
BaseImage = BaseImage.FromSsmParameterName("/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64"),
Components = new [] { new ComponentConfiguration {
Component = parameterizedComponent,
Parameters = new Dictionary<string, ComponentParameterValue> {
{ "environment", ComponentParameterValue.FromString("production") },
{ "version", ComponentParameterValue.FromString("1.0.0") }
}
} }
});
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
parameterizedComponent := imagebuilder.Component_FromComponentName(this, jsii.String("ParameterizedComponent"), jsii.String("my-parameterized-component"))
imageRecipe := imagebuilder.NewImageRecipe(this, jsii.String("ParameterizedImageRecipe"), &ImageRecipeProps{
BaseImage: imagebuilder.BaseImage_*FromSsmParameterName(jsii.String("/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64")),
Components: []ComponentConfiguration{
&ComponentConfiguration{
Component: parameterizedComponent,
Parameters: map[string]ComponentParameterValue{
"environment": imagebuilder.ComponentParameterValue_fromString(jsii.String("production")),
"version": imagebuilder.ComponentParameterValue_fromString(jsii.String("1.0.0")),
},
},
},
})
Initializer
new ImageRecipe(scope: Construct, id: string, props: ImageRecipeProps)
ImageRecipe(scope: Construct, id: str, props: ImageRecipeProps)
new ImageRecipe(Construct scope, String id, ImageRecipeProps props)
new ImageRecipe(Construct scope, string id, ImageRecipeProps props)
NewImageRecipe(Scope Construct, Id *string, Props ImageRecipeProps)
Construct Props
amiTags{ [key: string]: string }ami_tagstyping.Mapping[str, str]amiTagsMap<String, String>AmiTagsIDictionary<string, string>AmiTags*map[string]*string= None#baseImageBaseImagebase_imageBaseImagebaseImageBaseImageBaseImageBaseImageBaseImageBaseImagerequired#blockDevicesBlockDevice[]block_devicestyping.List[BlockDevice]blockDevicesList<BlockDevice>BlockDevicesBlockDevice[]BlockDevices*[]BlockDevice= None#componentsComponentConfiguration[]componentstyping.List[ComponentConfiguration]componentsList<ComponentConfiguration>ComponentsComponentConfiguration[]Components*[]ComponentConfiguration= None#imageRecipeNamestringimage_recipe_namestrimageRecipeNameStringImageRecipeNamestringImageRecipeName*string= a name is generated#imageRecipeVersionstringimage_recipe_versionstrimageRecipeVersionStringImageRecipeVersionstringImageRecipeVersion*string= 1.0.x#tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#uninstallSsmAgentAfterBuildbooleanuninstall_ssm_agent_after_buildbooluninstallSsmAgentAfterBuildBooleanUninstallSsmAgentAfterBuildboolUninstallSsmAgentAfterBuild*bool= this is false if the Systems Man…#default
Default: this is false if the Systems Manager agent is pre-installed on the base image. Otherwise, this is true.
userDataOverrideUserDatauser_data_overrideUserDatauserDataOverrideUserDataUserDataOverrideUserDataUserDataOverrideUserData= None#notes
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.
workingDirectorystringworking_directorystrworkingDirectoryStringWorkingDirectorystringWorkingDirectory*string= the Image Builder default workin…#default
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:/
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
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.
imageRecipeArnstringimage_recipe_arnstrimageRecipeArnStringImageRecipeArnstringImageRecipeArn*stringrequired#imageRecipeNamestringimage_recipe_namestrimageRecipeNameStringImageRecipeNamestringImageRecipeName*stringrequired#imageRecipeVersionstringimage_recipe_versionstrimageRecipeVersionStringImageRecipeVersionstringImageRecipeVersion*stringrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
addBlockDevice(...blockDevices: BlockDevice[]): voiddef add_block_device(self, block_devices: BlockDevice) -> Nonepublic void addBlockDevice(BlockDevice blockDevices)public void AddBlockDevice(BlockDevice blockDevices)func AddBlockDevice(BlockDevices BlockDevice)#1 parameter
Parameters
blockDevicesblock_devicesblockDevicesblockDevicesBlockDevices— The list of block devices to attach.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromImageRecipeArn(scope: Construct, id: string, imageRecipeArn: string): IImageRecipe@staticmethod def from_image_recipe_arn(scope: Construct, id: str, image_recipe_arn: str) -> IImageRecipepublic static IImageRecipe fromImageRecipeArn(Construct scope, String id, String imageRecipeArn)public static IImageRecipe FromImageRecipeArn(Construct scope, string id, string imageRecipeArn)func FromImageRecipeArn(Scope Construct, Id *string, ImageRecipeArn *string) IImageRecipestatic#fromImageRecipeAttributes(scope: Construct, id: string, attrs: ImageRecipeAttributes): IImageRecipe@staticmethod def from_image_recipe_attributes(scope: Construct, id: str, attrs: ImageRecipeAttributes) -> IImageRecipepublic static IImageRecipe fromImageRecipeAttributes(Construct scope, String id, ImageRecipeAttributes attrs)public static IImageRecipe FromImageRecipeAttributes(Construct scope, string id, ImageRecipeAttributes attrs)func FromImageRecipeAttributes(Scope Construct, Id *string, Attrs ImageRecipeAttributes) IImageRecipestatic#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.
fromImageRecipeName(scope: Construct, id: string, imageRecipeName: string): IImageRecipe@staticmethod def from_image_recipe_name(scope: Construct, id: str, image_recipe_name: str) -> IImageRecipepublic static IImageRecipe fromImageRecipeName(Construct scope, String id, String imageRecipeName)public static IImageRecipe FromImageRecipeName(Construct scope, string id, string imageRecipeName)func FromImageRecipeName(Scope Construct, Id *string, ImageRecipeName *string) IImageRecipestatic#The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#2 parameters
Parameters
granteegranteegranteegranteeGrantee— The principal.actionsactionsactionsactionsActions— The list of actions.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#1 parameter
Parameters
granteegranteegranteegranteeGrantee— The principal.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
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
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isImageRecipe(x: any): boolean@staticmethod def is_image_recipe(x: Any) -> boolpublic static Boolean isImageRecipe(Object x)public static bool IsImageRecipe(object x)func IsImageRecipe(X interface{}) *boolstatic#isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.