Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Image L2 construct
Represents an EC2 Image Builder Image.
Example
const containerRecipe = new imagebuilder.ContainerRecipe(this, 'MyContainerRecipe', {
baseImage: imagebuilder.BaseContainerImage.fromDockerHub('amazonlinux', 'latest'),
targetRepository: imagebuilder.Repository.fromEcr(
ecr.Repository.fromRepositoryName(this, 'Repository', 'my-container-repo')
)
});
const containerImage = new imagebuilder.Image(this, 'MyContainerImage', {
recipe: containerRecipe
});
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_image = imagebuilder.Image(self, "MyContainerImage",
recipe=container_recipe
)
ContainerRecipe containerRecipe = ContainerRecipe.Builder.create(this, "MyContainerRecipe")
.baseImage(BaseContainerImage.fromDockerHub("amazonlinux", "latest"))
.targetRepository(Repository.fromEcr(Repository.fromRepositoryName(this, "Repository", "my-container-repo")))
.build();
Image containerImage = Image.Builder.create(this, "MyContainerImage")
.recipe(containerRecipe)
.build();
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var containerRecipe = new ContainerRecipe(this, "MyContainerRecipe", new ContainerRecipeProps {
BaseImage = BaseContainerImage.FromDockerHub("amazonlinux", "latest"),
TargetRepository = Repository.FromEcr(Repository.FromRepositoryName(this, "Repository", "my-container-repo"))
});
var containerImage = new Image(this, "MyContainerImage", new ImageProps {
Recipe = containerRecipe
});
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
containerRecipe := imagebuilder.NewContainerRecipe(this, jsii.String("MyContainerRecipe"), &ContainerRecipeProps{
BaseImage: imagebuilder.BaseContainerImage_*FromDockerHub(jsii.String("amazonlinux"), jsii.String("latest")),
TargetRepository: imagebuilder.Repository_*FromEcr(ecr.Repository_*FromRepositoryName(this, jsii.String("Repository"), jsii.String("my-container-repo"))),
})
containerImage := imagebuilder.NewImage(this, jsii.String("MyContainerImage"), &ImageProps{
Recipe: containerRecipe,
})
Initializer
new Image(scope: Construct, id: string, props: ImageProps)
Image(scope: Construct, id: str, props: ImageProps)
new Image(Construct scope, String id, ImageProps props)
new Image(Construct scope, string id, ImageProps props)
NewImage(Scope Construct, Id *string, Props ImageProps)
Construct Props
deletionExecutionRoleIRoledeletion_execution_roleIRoledeletionExecutionRoleIRoleDeletionExecutionRoleIRoleDeletionExecutionRoleIRole#Default: no execution role. Only the Image Builder image will be deleted.
This role should contain resource lifecycle permissions required to delete the underlying AMIs/containers.
distributionConfigurationIDistributionConfigurationdistribution_configurationIDistributionConfigurationdistributionConfigurationIDistributionConfigurationDistributionConfigurationIDistributionConfigurationDistributionConfigurationIDistributionConfiguration= None#enhancedImageMetadataEnabledbooleanenhanced_image_metadata_enabledboolenhancedImageMetadataEnabledBooleanEnhancedImageMetadataEnabledboolEnhancedImageMetadataEnabled*bool= true#Default: Image Builder will use the SLR if possible. Otherwise, an execution role will be generated
notes
By default, the Image Builder Service Linked Role (SLR) will be created automatically and used as the execution role. However, when providing a custom set of image workflows for the image, an execution role will be generated with the minimal permissions needed to execute the workflows.
imageScanningEcrRepositoryIRepositoryimage_scanning_ecr_repositoryIRepositoryimageScanningEcrRepositoryIRepositoryImageScanningEcrRepositoryIRepositoryImageScanningEcrRepositoryIRepository#Default: if scanning is enabled, a repository will be created by Image Builder if one is not provided
If a repository is not provided, Image Builder creates a repository named image-builder-image-scanning-repository for vulnerability scanning.
imageScanningEcrTagsstring[]image_scanning_ecr_tagstyping.List[str]imageScanningEcrTagsList<String>ImageScanningEcrTagsstring[]ImageScanningEcrTags*[]*string= None#imageScanningEnabledbooleanimage_scanning_enabledboolimageScanningEnabledBooleanImageScanningEnabledboolImageScanningEnabled*bool= false#imageTestsEnabledbooleanimage_tests_enabledboolimageTestsEnabledBooleanImageTestsEnabledboolImageTestsEnabled*bool= true#infrastructureConfigurationIInfrastructureConfigurationinfrastructure_configurationIInfrastructureConfigurationinfrastructureConfigurationIInfrastructureConfigurationInfrastructureConfigurationIInfrastructureConfigurationInfrastructureConfigurationIInfrastructureConfiguration#Default: an infrastructure configuration will be created with the default settings
notes
A default infrastructure configuration will be used if one is not provided.
The default configuration will create an instance profile and role with minimal permissions needed to build the image, attached to the EC2 instance.
IMDSv2 will be required by default on the instances used to build and test the image.
Default: a log group will be created
By default, a log group will be created with the format /aws/imagebuilder/<image-name>
This can either be an image recipe, or a container recipe.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#workflowsWorkflowConfiguration[]workflowstyping.List[WorkflowConfiguration]workflowsList<WorkflowConfiguration>WorkflowsWorkflowConfiguration[]Workflows*[]WorkflowConfiguration#Default: Image Builder will use a default set of workflows for the build to build, test, and distribute the image
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.
infrastructureConfigurationIInfrastructureConfigurationinfrastructure_configurationIInfrastructureConfigurationinfrastructureConfigurationIInfrastructureConfigurationInfrastructureConfigurationIInfrastructureConfigurationInfrastructureConfigurationIInfrastructureConfigurationrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
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).
fromImageArn(scope: Construct, id: string, imageArn: string): IImage@staticmethod def from_image_arn(scope: Construct, id: str, image_arn: str) -> IImagepublic static IImage fromImageArn(Construct scope, String id, String imageArn)public static IImage FromImageArn(Construct scope, string id, string imageArn)func FromImageArn(Scope Construct, Id *string, ImageArn *string) IImagestatic#fromImageAttributes(scope: Construct, id: string, attrs: ImageAttributes): IImage@staticmethod def from_image_attributes(scope: Construct, id: str, attrs: ImageAttributes) -> IImagepublic static IImage fromImageAttributes(Construct scope, String id, ImageAttributes attrs)public static IImage FromImageAttributes(Construct scope, string id, ImageAttributes attrs)func FromImageAttributes(Scope Construct, Id *string, Attrs ImageAttributes) IImagestatic#If the image 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.
fromImageName(scope: Construct, id: string, imageName: string): IImage@staticmethod def from_image_name(scope: Construct, id: str, image_name: str) -> IImagepublic static IImage fromImageName(Construct scope, String id, String imageName)public static IImage FromImageName(Construct scope, string id, string imageName)func FromImageName(Scope Construct, Id *string, ImageName *string) IImagestatic#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#[disable-awslint:no-grants]
2 parameters
Parameters
granteegranteegranteegranteeGrantee— The principal.actionsactionsactionsactionsActions— The list of actions.
grantDefaultExecutionRolePermissions(grantee: IGrantable): Grant[]def grant_default_execution_role_permissions(self, grantee: IGrantable) -> typing.List[Grant]public List<Grant> grantDefaultExecutionRolePermissions(IGrantable grantee)public Grant[] GrantDefaultExecutionRolePermissions(IGrantable grantee)func GrantDefaultExecutionRolePermissions(Grantee IGrantable) *[]Grant#[disable-awslint:no-grants]
1 parameter
Parameters
granteegranteegranteegranteeGrantee— The execution role used for the image build.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#[disable-awslint:no-grants]
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.
isImage(x: any): boolean@staticmethod def is_image(x: Any) -> boolpublic static Boolean isImage(Object x)public static bool IsImage(object x)func IsImage(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#toBaseImage(): BaseImagedef to_base_image(self, ) -> BaseImagepublic BaseImage toBaseImage()public BaseImage ToBaseImage()func ToBaseImage() BaseImage#toContainerBaseImage(): BaseContainerImagedef to_container_base_image(self, ) -> BaseContainerImagepublic BaseContainerImage toContainerBaseImage()public BaseContainerImage ToContainerBaseImage()func ToContainerBaseImage() BaseContainerImage#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.