@aws-cdk/aws-imagebuilder-alpha module
| Language | Package |
|---|---|
.NET | Amazon.CDK.AWS.ImageBuilder.Alpha |
Go | github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2 |
Java | software.amazon.awscdk.services.imagebuilder.alpha |
Python | aws_cdk.aws_imagebuilder_alpha |
TypeScript | @aws-cdk/aws-imagebuilder-alpha |
EC2 Image Builder Construct Library
The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
This module is part of the AWS Cloud Development Kit project.
README
Amazon EC2 Image Builder is a fully managed AWS service that helps you automate the creation, management, and deployment of customized, secure, and up-to-date server images. You can use Image Builder to create Amazon Machine Images (AMIs) and container images for use across AWS Regions.
This module is part of the AWS Cloud Development Kit project. It allows you to define Image Builder pipelines, images, recipes, components, workflows, and lifecycle policies. A component defines the sequence of steps required to customize an instance during image creation (build component) or test an instance launched from the created image (test component). Components are created from declarative YAML or JSON documents that describe runtime configuration for building, validating, or testing instances. Components are included when added to the image recipe or container recipe for an image build.
EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketplace components, and custom components that you create. Components run during specific workflow phases: build and validate phases during the build stage, and test phase during the test stage.
Infrastructure Configuration
Infrastructure configuration defines the compute resources and environment settings used during the image building process. This includes instance types, IAM instance profile, VPC settings, subnets, security groups, SNS topics for notifications, logging configuration, and troubleshooting settings like whether to terminate instances on failure or keep them running for debugging. These settings are applied to builds when included in an image or an image pipeline.
const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration(this, 'InfrastructureConfiguration', {
infrastructureConfigurationName: 'test-infrastructure-configuration',
description: 'An Infrastructure Configuration',
// Optional - instance types to use for build/test
instanceTypes: [
ec2.InstanceType.of(ec2.InstanceClass.STANDARD7_INTEL, ec2.InstanceSize.LARGE),
ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.LARGE)
],
// Optional - create an instance profile with necessary permissions
instanceProfile: new iam.InstanceProfile(this, 'InstanceProfile', {
instanceProfileName: 'test-instance-profile',
role: new iam.Role(this, 'InstanceProfileRole', {
assumedBy: iam.ServicePrincipal.fromStaticServicePrincipleName('ec2.amazonaws.com'),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'),
iam.ManagedPolicy.fromAwsManagedPolicyName('EC2InstanceProfileForImageBuilder')
]
})
}),
// Use VPC network configuration
vpc,
subnetSelection: { subnetType: ec2.SubnetType.PUBLIC },
securityGroups: [ec2.SecurityGroup.fromSecurityGroupId(this, 'SecurityGroup', vpc.vpcDefaultSecurityGroup)],
keyPair: ec2.KeyPair.fromKeyPairName(this, 'KeyPair', 'imagebuilder-instance-key-pair'),
terminateInstanceOnFailure: true,
// Optional - IMDSv2 settings
httpTokens: imagebuilder.HttpTokens.REQUIRED,
httpPutResponseHopLimit: 1,
// Optional - publish image completion messages to an SNS topic
notificationTopic: sns.Topic.fromTopicArn(
this,
'Topic',
this.formatArn({ service: 'sns', resource: 'image-builder-topic' })
),
// Optional - log settings. Logging is enabled by default
logging: {
s3Bucket: s3.Bucket.fromBucketName(this, 'LogBucket', `imagebuilder-logging-${Aws.ACCOUNT_ID}`),
s3KeyPrefix: 'imagebuilder-logs'
},
// Optional - host placement settings
ec2InstanceAvailabilityZone: Stack.of(this).availabilityZones[0],
ec2InstanceHostId: dedicatedHost.attrHostId,
ec2InstanceTenancy: imagebuilder.Tenancy.HOST,
resourceTags: {
Environment: 'production'
}
});

.NET
Go
Java
Python
TypeScript