Skip to content

amiIdSsmPath creates SSM parameter with DataType: text instead of aws:ec2:image, breaking ASG Instance Refresh #290

@AndrewChemis

Description

@AndrewChemis

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

  1. 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,
});
  1. Create a Launch Template using the SSM parameter:
const launchTemplate = new LaunchTemplate(this, 'launch-template', {
  machineImage: MachineImage.fromSsmParameter('/my/ami/parameter'),
});
  1. Create an ASG with the Launch Template
  2. Run the Image Builder pipeline (creates the SSM parameter)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions