-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDK Tagging: Stacks dont resolve Tags and autoDeleteObjects in S3 causes Stack level tagging to fail validation #31423
Comments
Relevant? #30515 |
And 1 more issue is that I suspect that passing that ARN is causing my other stacks to need 'updating' even when there is no change. |
@ryanm101 Good afternoon. Thanks for reporting the issue. I tried reproducing the issue using CDK version The 1st scenario (for The 2nd scenario (for
It also doesn't work if I change code so that Producer emits
It's failing during creation of Upon searching CDK repo for other related issues, this appears to be similar to #31090, which also has possible reasoning behind it. Could you please check? Thanks, |
@ashishdhingra it's reproducible with my repro above |
i agree @ashishdhingra issue 2 does look related to #31090 @gshpychka was able to reproduce the Token Literal so I don't think it is just me also per his note there is an issue3 which is that Issue 1 was also applied to the consumer_ValidationFail if you look at the stack created even though the resources fail. |
Experiencing the same error, but on
|
I've had the same issue standing up an ALB: import { Vpc, SubnetType, InstanceType, SecurityGroup, Peer, Port } from 'aws-cdk-lib/aws-ec2';
import { ApplicationLoadBalancer, ApplicationProtocol } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import { AutoScalingGroup } from 'aws-cdk-lib/aws-autoscaling';
import { AmazonLinuxImage } from 'aws-cdk-lib/aws-ec2';
import { Stack, StackProps, Tags} from "aws-cdk-lib";
import {Construct} from "constructs";
interface AlbStackProps extends StackProps {
applicationTagValue: string,
config: any,
}
export class AlbStack extends Stack {
public readonly alb: ApplicationLoadBalancer;
constructor(scope: Construct, id: string, props: AlbStackProps) {
super(scope, id, props);
// Tagging fails: https:/aws/aws-cdk/issues/31423 if using CustomVpcRestrictD same as front end issue
console.log(`[WARN] Stack Tagging disbaled for '${props.config.global.name}-Alb' due to: https:/aws/aws-cdk/issues/31423`)
//Tags.of(this).add('awsApplication', props.applicationTagValue);
Tags.of(this).add('Application', props.config.global.name);
// Create a VPC for the ALB
const vpc = new Vpc(this, 'MyVPC', {
maxAzs: 2,
});
// Create a security group for the ALB
const albSecurityGroup = new SecurityGroup(this, 'ALBSecurityGroup', {
vpc,
allowAllOutbound: true,
});
albSecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(80)); // Allow HTTP traffic to ALB
// Create an internal ALB
const alb = new ApplicationLoadBalancer(this, 'MyInternalALB', {
vpc,
internetFacing: false, // This makes it internal
vpcSubnets: {
subnetType: SubnetType.PRIVATE_WITH_EGRESS, // SubnetType where ALB will live
},
securityGroup: albSecurityGroup,
});
// Add a listener to the ALB (HTTP)
const listener = alb.addListener('Listener', {
port: 80,
protocol: ApplicationProtocol.HTTP,
});
// Auto-scaling group for backend (example for EC2)
const asg = new AutoScalingGroup(this, 'MyASG', {
vpc,
instanceType: new InstanceType('t2.micro'),
machineImage: new AmazonLinuxImage(),
});
// Register the backend instances with the ALB listener
listener.addTargets('Targets', {
port: 80,
targets: [asg],
});
this.alb = alb;
}
} |
2.161.1 (build 0a606c9) I now get: |
Yup - fixed in #31457. |
Describe the bug
I see two issues when Tagging at a Stack level.
At the Stack level awsApplication is set to a TOKEN Literal:
${Token[TOKEN.15]}
When create an S3 Resource and setting the
autoDeleteObjects
property totrue
I get a validation error. I suspect it is passing the Token Literal OR there is a permission issue.On Issue 2 using this:
Tags.of(this).add('awsApplication', Fn.importValue('AppTag'));
results in
Failing at the step: CustomS3AutoDeleteObjectsCustomResourceProviderRole
Using:
Tags.of(this).add('awsApplication', Lazy.string({ produce: () => Fn.importValue('AppTag'),}));
Results in:
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
In the case of Number 1: I expect the Stack to be tagged with the ARN passed in.
In the case of Number 2: I expect the Stack to not Fail with a validation error and my bucket get created with the correct tags.
Current Behavior
See Description
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.158.0 (build 4b8714d)
Framework Version
No response
Node.js Version
Node.js v22.8.0
OS
MacOS (latest)
Language
TypeScript
Language Version
TypeScript 5.5.3
Other information
Slack Thread detailing troubleshooting: https://cdk-dev.slack.com/archives/C018XT6REKT/p1725979817118299
The text was updated successfully, but these errors were encountered: