-
Notifications
You must be signed in to change notification settings - Fork 4k
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 Deploy): (Elastic IP tags are not created as part of creation process) #26878
Comments
The way I would propose that you solve this is to use a CDK Aspect on the stack. CDK Aspects are run before the whole tree is synthesized into what will become CloudFormation templates, and allow you to modify the tree of items just before they are reified into CloudFormation templates. They implement a Visitor pattern. This will allow you to ensure that the tags of a construct down to a CloudFormation item in a deeper construct are tagged appropriately. For more information, see: https://docs.aws.amazon.com/cdk/v2/guide/aspects.html |
|
Hi @peterwoodworth , I see that tag |
If the template is synthesizing with tags (which it is), and you've properly tracked down that this is an issue with the tags on the |
Also - I wasn't able to reproduce the issue with the CDK snippet provided. It appears the Cfn template you provided might be different than the one the CDK code you provided would synthesize though |
Hi @peterwoodworth - Thanks for looking. I don't think you can reproduce the issue unless your AWS account your testing in has a service control policy that blocks the creation of elastic IP addresses without specific tags created with the resource? That is the root issue, we don't allow resources to be created unless they have an For example, our SCP as it relates to Elastic IP tagging looks something like this:
If I remove these sections from our SCP, the CDK succeeds in creating the Elastic IP addresses. |
Right sorry - However, I am seeing that the tags are properly deploying on my end. If I were to make a guess, I'd guess that the CloudFormation implementation of this resource likely creates the resource, and then adds tags with a subsequent API call. Which would break an SCP like this. If you have premium support I suggest reaching out to them, else I can create a ticket internally |
I did submit a ticket in AWS and got a response that they were able to see the same behavior on their end. This can be replicated when using just Cloudformation as well. They tried deploying the below Template: MyVpcPublicSubnet1EIP096967CB: Creation of AWS::EC2::EIP Resource, currently triggers a "AllocateAddress" API followed with a separate “CreateTags” API Call which tags the resource. Due to this the creation of AWS::EC2::EIP fails because the SCP on expects the Tags to be passed in the same AllocateAddress API. It looks like the only thing to do is to wait for the CloudFormation team to address this on their side. My understanding is that this is not a CDK issue and so having this remained closed is appropriate. |
Yeah makes sense, thanks for getting back to me |
|
Just in case anyone else stumbles upon this thread... The AWS CloudFormation team pushed a fix for this on 2023-10-21 and I was able to validate that with my workflow above I no longer see the issue. Adding a tag to an elastic IP at creation time is now supported in CloudFormation, and by extension through the CDK. |
Describe the bug
We have an AWS Service Control Policy (SCP) applied from our organization that prevents the creation of new resources if they dont have an
owner
tag in the format of an email. This has not been an issue for creation resources using the AWS console, the AWS CLI, or Python3 with boto3, however, it appears to be an issue with the AWS CDK.The issue does not happen with instances and volumes with the same restrictions, only Elastic IP's.
I am guessing the issue is that with the CDK, the Elastic IP is created, then tags are applied after the Elastic IP has been created but I am not sure.
Here is my sample code the reproduces the problem:
When I run
cdk synth
, I see the proper tags on the EIP's:However when I run
cdk deploy
I get errors :Decoding the error message shows me the issue is the SCP for Elastic IP's not being properly tagged.
I have tried variations of using ec2.CfnVPC but none of those worked.
If I remove the SCP section for elastic IP
owner
tag and keep the same policy for instances and volumes I am able to successfully deploy my stack.Expected Behavior
Successful deployment of my CDK stack
Current Behavior
Failure to deploy due to the Elastic IP not being tagged at creation time.
Reproduction Steps
Here is my sample code the reproduces the problem:
When I run
cdk synth
, I see the proper tags on the EIP's:However when I run
cdk deploy
I get errors :Decoding the error message shows me the issue is the SCP for Elastic IP's not being properly tagged.
I have tried variations of using ec2.CfnVPC but none of those worked.
If I remove the SCP section for elastic IP
owner
tag and keep the same policy for instances and volumes I am able to successfully deploy my stack.Possible Solution
Similar to how the CDK has a
propagate_tags_to_volume_on_creation=True
flag it would be good if we could do this for Elastic IP's?Additional Information/Context
No response
CDK CLI Version
2.86.0 (build 1130fab)
Framework Version
No response
Node.js Version
v16.20.1
OS
AWS Linux - 4.14.255-314-253.539.amzn2.x86_64
Language
Python
Language Version
Python 3.7.16
Other information
chatGPT gave me these helpful nuggets of information :)
Currently, the CDK does not have a direct way to add tags during EIP creation when using the low-level CfnEIP construct. This makes it tricky when SCPs require tags upon resource creation, as is your case.
Feedback to AWS: If you believe this is an issue with how CDK is handling the Elastic IP creation and tagging process, you might want to provide feedback to AWS or raise it in the AWS CDK GitHub repository.
The text was updated successfully, but these errors were encountered: