Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
BaseContainerImage Class
Represents a base image that is used to start from in EC2 Image Builder image builds.
Example
ts
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')
}
}
]
});
python
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")
}
)
]
)
java
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();
csharp
// 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") }
}
} }
});
go
// 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")),
},
},
},
})
Properties
The rendered base image to use.
Methods
fromDockerHub(repository: string, tag: string): BaseContainerImage // chainable@staticmethod def from_docker_hub(repository: str, tag: str) -> BaseContainerImagepublic static BaseContainerImage fromDockerHub(String repository, String tag)public static BaseContainerImage FromDockerHub(string repository, string tag)func FromDockerHub(Repository *string, Tag *string) BaseContainerImagestatic#The DockerHub image to use as the base image in a container recipe.
2 parameters
Parameters
repositoryrepositoryrepositoryrepositoryRepository— The DockerHub repository where the base image resides in.tagtagtagtagTag— The tag of the base image in the DockerHub repository.
fromEcr(repository: IRepository, tag: string): BaseContainerImage // chainable@staticmethod def from_ecr(repository: IRepository, tag: str) -> BaseContainerImagepublic static BaseContainerImage fromEcr(IRepository repository, String tag)public static BaseContainerImage FromEcr(IRepository repository, string tag)func FromEcr(Repository IRepository, Tag *string) BaseContainerImagestatic#The ECR container image to use as the base image in a container recipe.
2 parameters
Parameters
repositoryrepositoryrepositoryrepositoryRepository— The ECR repository where the base image resides in.tagtagtagtagTag— The tag of the base image in the ECR repository.
fromEcrPublic(registryAlias: string, repositoryName: string, tag: string): BaseContainerImage // chainable@staticmethod def from_ecr_public(registry_alias: str, repository_name: str, tag: str) -> BaseContainerImagepublic static BaseContainerImage fromEcrPublic(String registryAlias, String repositoryName, String tag)public static BaseContainerImage FromEcrPublic(string registryAlias, string repositoryName, string tag)func FromEcrPublic(RegistryAlias *string, RepositoryName *string, Tag *string) BaseContainerImagestatic#The ECR public container image to use as the base image in a container recipe.
3 parameters
Parameters
registryAliasregistry_aliasregistryAliasregistryAliasRegistryAlias— The alias of the ECR public registry where the base image resides in.repositoryNamerepository_namerepositoryNamerepositoryNameRepositoryName— The name of the ECR public repository, where the base image resides in.tagtagtagtagTag— The tag of the base image in the ECR public repository.
fromImage(image: IImage): BaseContainerImage // chainable@staticmethod def from_image(image: IImage) -> BaseContainerImagepublic static BaseContainerImage fromImage(IImage image)public static BaseContainerImage FromImage(IImage image)func FromImage(Image IImage) BaseContainerImagestatic#The EC2 Image Builder image to use as a base image in a container recipe.
1 parameter
Parameters
imageimageimageimageImage— The EC2 Image Builder image to use as a base image.
fromString(baseContainerImageString: string): BaseContainerImage // chainable@staticmethod def from_string(base_container_image_string: str) -> BaseContainerImagepublic static BaseContainerImage fromString(String baseContainerImageString)public static BaseContainerImage FromString(string baseContainerImageString)func FromString(BaseContainerImageString *string) BaseContainerImagestatic#The string value of the base image to use in a container recipe.
This can be an EC2 Image Builder image ARN, an ECR or ECR public image, or a container URI sourced from a third-party container registry such as DockerHub.
1 parameter
Parameters
baseContainerImageStringbase_container_image_stringbaseContainerImageStringbaseContainerImageStringBaseContainerImageString— The base image as a direct string value.