#38390·aws-cdk

core: CloudFormation-Validate::W9010

Author: Joe-Zer0Created Jul 23, 2026Updated Sep 18, 2026
Labelsbugp2@aws-cdk/core

Describe the bug

Doing this in CDK (Python):

aws_ec2.Instance(
...
machine_image=aws_ec2.MachineImage.generic_linux(ami_map={Stack.of(self).region: aws_ec2.LookupMachineImage(name=ami_name).get_image(self).image_id)}

Generates the following CFN:

  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
...
      ImageId: ami-######

'''

Running `cdk synth` generates the following warning:

WARNING ImageId: Hardcoded AMI ID - use a parameter or mapping for portability (CloudFormation Validate) test-emc-cdk-lib/EmcEc21/Resource (EmcEc21FC170D30) aws-cdk-lib.aws_ec2.CfnInstance Acknowledge with 'CloudFormation-Validate::W9010'

In CDK determining values via the code as opposed to via a map is common practice and should not throw warnings.
I believe this issue was introduced in this change - https://github.com/aws/aws-cdk/pull/38135.
A potential fix would be to add this to error code here - https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/validation/cloudformation-validate-plugin.ts#L182.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

_No response_

### Expected Behavior

I expect the synth to complete without warnings.

### Current Behavior

Running `cdk synth` generates the following warning:

WARNING ImageId: Hardcoded AMI ID - use a parameter or mapping for portability (CloudFormation Validate) test-emc-cdk-lib/EmcEc21/Resource (EmcEc21FC170D30) aws-cdk-lib.aws_ec2.CfnInstance Acknowledge with 'CloudFormation-Validate::W9010'


### Reproduction Steps

In description

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

v2.262.0

### AWS CDK CLI version

2.1132.1

### Node.js Version

v24.18.0

### OS

Windows

### Language

Python

### Language Version

_No response_

### Other information

_No response_