aws / aws/aws-cdk

(ec2): CloudFormation-Validate::W9010 false positive when AMI ID is cached in context

Open
#38,824 0 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug needs-triage potential-regression
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

Same issue as #38423... CloudFormation-Validate::W9010 is reported when cachedInContext: true for ec2.MachineImage.latestAmazonLinux2023()

### Regression Issue

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

### Last Known Working CDK Library Version

_No response_

### Expected Behavior

No warning message

### Current Behavior

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

### Reproduction Steps

```
new ec2.Instance(stack, 'Instance', {
machineImage: ec2.MachineImage.latestAmazonLinux2023({ cachedInContext: true }),
...
});
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

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

2.268.0

### AWS CDK CLI version

2.1140.0

### Node.js Version

22

### OS

Mac

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the warning with ec2.MachineImage.latestAmazonLinux2023({ cachedInContext: true }) and compare the behavior with issue #38423. Trace how the CloudFormation-Validate::W9010 check sees the cached AMI, then verify the reproduction no longer emits the warning while retaining the portability warning for genuinely hardcoded AMI IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.