core: CloudFormation-Validate::W9007 false positive when subnet id is Fn::GetStackOutput
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
`CloudFormation-Validate::W9007` is reported on Application Load Balancer, ElastiCache SubnetGroup, and RDS SubnetGroup when subnets are imported from another stack using `Fn::GetStackOutput`.
Feature flag `@aws-cdk/core:defaultCrossStackReferences` is `weak`.
```ts
new elbv2.ApplicationLoadBalancer(stack, 'ALB', {
vpc: anotherStack.vpc,
...
});
```
Template:
```json5
{
"Resource": {
"ALBXXXX": {
"Type": "ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
// ...
"Subnets": [
{
"Fn::GetStackOutput": {
"StackName": "XXX",
"Region": "ap-northeast-1",
"OutputName": "PublishOutputRefVpcIsolatedSubnet1SubnetXXX"
}
},
{
"Fn::GetStackOutput": {
"StackName": "XXX",
"Region": "ap-northeast-1",
"OutputName": "PublishOutputRefVpcIsolatedSubnet2SubnetXXX"
}
},
{
"Fn::GetStackOutput": {
"StackName": "XXX",
"Region": "ap-northeast-1",
"OutputName": "PublishOutputRefVpcIsolatedSubnet3SubnetXXX"
}
}
],
"Type": "application"
}
}
}
}
```
> WARNING Subnets: Array property 'Subnets' contains duplicate values (CloudFormation Validate)
> aws-cdk-lib.aws_elasticloadbalancingv2.CfnLoadBalancer
> Acknowledge with 'CloudFormation-Validate::W9007'
Same issue on aws-cdk-lib.aws_elasticache.CfnSubnetGroup and aws-cdk-lib.aws_rds.CfnDBSubnetGroup.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
No warnigns are reported.
### Current Behavior
See description above.
### Reproduction Steps
See description above.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.262.1
### AWS CDK CLI version
2.1133.0 (build 712d792)
### Node.js Version
v24.18.0
### OS
Linux
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Reproduce the warning with the supplied CloudFormation template and the Application Load Balancer, ElastiCache SubnetGroup, or RDS SubnetGroup examples using Fn::GetStackOutput. Trace the CloudFormation-Validate::W9007 handling and verify that subnet values imported this way no longer produce duplicate-value warnings.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100