-
Notifications
You must be signed in to change notification settings - Fork 4.5k
CfnLoadBalancer: CfnInclude broken for conditional tags #30740
Copy link
Copy link
Closed
Labels
@aws-cdk/cloudformation-includeIssues related to the "CFN include v.20" packageIssues related to the "CFN include v.20" package@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1
Description
Describe the bug
When you attempt to CfnInclude a AWS::ElasticLoadBalancingV2::LoadBalancer resource with valid conditional tags CDK errors out
Expected Behavior
CfnInclude should succeed
Current Behavior
An error is thrown:
CfnSynthesisError: Resolution error: Supplied properties not correct for "CfnLoadBalancerProps"
tags: element 1: {} should have a 'key' and a 'value' property.
Reproduction Steps
Create a stack and include the following:
const template = `{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"IsExtraTag": {
"Type": "String",
"AllowedValues": [
"true",
"false"
],
"Default": "false"
}
},
"Conditions": {
"AddExtraTag": {
"Fn::Equals": [
{
"data": "IsExtraTag",
"type": "Ref",
"isCfnFunction": true
},
"true"
]
}
},
"Resources": {
"MyLoadBalancer": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"Name": "my-load-balancer",
"Subnets": [
"subnet-0123456789abcdef0"
],
"SecurityGroups": [
"sg-0123456789abcdef0"
],
"Scheme": "internet-facing",
"LoadBalancerAttributes": [
{
"Key": "idle_timeout.timeout_seconds",
"Value": "60"
}
],
"IpAddressType": "ipv4",
"Tags": [
{
"Key": "Name",
"Value": "MyLoadBalancer"
},
{
"data": [
"IsExtraTag",
{
"Key": "Name2",
"Value": "MyLoadBalancer2"
},
{
"data": "AWS::NoValue",
"type": "Ref",
"isCfnFunction": true
}
],
"type": "Fn::If",
"isCfnFunction": true
}
]
}
}
}
}`;
const tmpobj = tmp.fileSync();
fs.writeFileSync(tmpobj.fd, template);
new CfnInclude(this, 'MyStack', {
templateFile: tmpobj.name
});
tmpobj.removeCallback();
You will get the exception
CfnSynthesisError: Resolution error: Supplied properties not correct for "CfnLoadBalancerProps"
tags: element 1: {} should have a 'key' and a 'value' property.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.87.0
Framework Version
No response
Node.js Version
v18.18.2
OS
AL2
Language
TypeScript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/cloudformation-includeIssues related to the "CFN include v.20" packageIssues related to the "CFN include v.20" package@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1