-
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
(@aws-ec2): Using require_imdsv2=True creates non-unique launch templates #17656
Comments
The stacks creating resources with identical names is intentional! With the Let me know if this clears up the confusion |
instance_name isn't the issue in this case. I understand that by setting instance_name, I'm setting the Name tag for the instant being created. The problem is that if you specify require_imdsv2=True, then a Launch Template is created to apply the IMDSv2 configuration. When the Launch Template is created, it is created using the second parameter "BastionInstance". It creates a Launch Template with the name "BastionInstanceLaunchTemplate". There should at least be a stack identifier applied to the Launch Template name to avoid possible duplication. |
@peterwoodworth There is. In my testing, I noticed the I missed these use cases in my original implementation, so I'll make a PR to fix it. |
…nder feature flag) (#17766) Fixes #17656 ### Notes Changes the name for the `LaunchTemplate` created in the aspect that enforces IMDSv2 on EC2 instances to a unique name. Introduces a new feature flag (`@aws-cdk/aws-ec2:uniqueImdsv2TemplateName`) to change the launch template name. ### Testing Added a unit test ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…nder feature flag) (aws#17766) Fixes aws#17656 ### Notes Changes the name for the `LaunchTemplate` created in the aspect that enforces IMDSv2 on EC2 instances to a unique name. Introduces a new feature flag (`@aws-cdk/aws-ec2:uniqueImdsv2TemplateName`) to change the launch template name. ### Testing Added a unit test ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
What is the problem?
When creating an EC2 instance that has require_imdsv2=True, the module utilizes ASG Launch templates to enforce the IMDSv2 configuration by creating a Launch Template. The Launch Template name is identical to the ID parameter passed during the instance creation. If you have more than one stack in the same account/region that utilizes a standard code base where the id parameters are identical, the second stack will always fail to create complaining of duplicate Launch Template names.
Reproduction Steps
Attempt to deploy two stacks with bastion instances that incorporates this code.
Bastion EC2 Instance
What did you expect to happen?
When the launch template is created it would prefix or suffix the Launch Template with stack unique identifiers to avoid duplicate names.
What actually happened?
The second stack attempted to create a Launch Template with an identical name.
BastionInstanceLaunchTemplate already exists in stack ......
CDK CLI Version
1.33.0
Framework Version
No response
Node.js Version
14.16.1
OS
MacOS
Language
Python
Language Version
Python 3.9
Other information
No response
The text was updated successfully, but these errors were encountered: