When using amiIdSsmPath to have Image Builder write the output AMI ID to an SSM parameter, the parameter is created with DataType: text. This breaks Auto Scaling Group Instance Refresh when the Launch Template uses resolve:ssm: syntax, as AWS requires DataType: aws:ec2:image for this use case.
Expected Behavior
When amiIdSsmPath is configured, Image Builder should create the SSM parameter with DataType: aws:ec2:image so it's compatible with Launch Template dynamic AMI resolution and ASG Instance Refresh.
Actual Behavior
The SSM parameter is created with DataType: text, causing Instance Refresh to fail with:
An error occurred (ValidationError) when calling the StartInstanceRefresh operation:
Unsupported data type. The following parameter data types are supported: aws:ec2:image
Steps to Reproduce
- Create an Image Pipeline with
amiIdSsmPath configured:
const imagePipeline = new ImagePipeline(this, 'image-pipeline', {
// ... other config
amiIdSsmPath: '/my/ami/parameter',
amiIdSsmAccountId: Stack.of(this).account,
amiIdSsmRegion: Stack.of(this).region,
});
- Create a Launch Template using the SSM parameter:
const launchTemplate = new LaunchTemplate(this, 'launch-template', {
machineImage: MachineImage.fromSsmParameter('/my/ami/parameter'),
});
- Create an ASG with the Launch Template
- Run the Image Builder pipeline (creates the SSM parameter)
- Attempt to start an Instance Refresh on the ASG
Workaround
Pre-create the SSM parameter in CDK with the correct data type before Image Builder runs:
new StringParameter(this, 'ami-parameter', {
parameterName: '/my/ami/parameter',
stringValue: 'ami-placeholder',
dataType: ParameterDataType.AWS_EC2_IMAGE,
});
Image Builder will then update only the value, preserving the data type.
Suggested Fix
Add an optional property to configure the SSM parameter data type, or default to aws:ec2:image since the parameter is specifically for AMI IDs:
interface ImagePipelineProps {
// existing props...
amiIdSsmPath?: string;
amiIdSsmDataType?: 'text' | 'aws:ec2:image'; // default to 'aws:ec2:image'
}
Environment
cdk-image-pipeline version: 0.5.133
aws-cdk-lib version: 2.218.0
- Node.js version: 24.x
References
When using
amiIdSsmPathto have Image Builder write the output AMI ID to an SSM parameter, the parameter is created withDataType: text. This breaks Auto Scaling Group Instance Refresh when the Launch Template usesresolve:ssm:syntax, as AWS requiresDataType: aws:ec2:imagefor this use case.Expected Behavior
When
amiIdSsmPathis configured, Image Builder should create the SSM parameter withDataType: aws:ec2:imageso it's compatible with Launch Template dynamic AMI resolution and ASG Instance Refresh.Actual Behavior
The SSM parameter is created with
DataType: text, causing Instance Refresh to fail with:Steps to Reproduce
amiIdSsmPathconfigured:Workaround
Pre-create the SSM parameter in CDK with the correct data type before Image Builder runs:
Image Builder will then update only the value, preserving the data type.
Suggested Fix
Add an optional property to configure the SSM parameter data type, or default to
aws:ec2:imagesince the parameter is specifically for AMI IDs:Environment
cdk-image-pipelineversion: 0.5.133aws-cdk-libversion: 2.218.0References