- Newest
- Most votes
- Most comments
Hi Guys,
My request has been resolved by AWS Support with following issue description :
==================================================
From the public docs, "When you create an EC2 instance with AWS CloudFormation using the resource AWS::EC2::Instance, AWS CloudFormation makes two API calls: RunInstances and CreateTags. RunInstances creates the instance and CreateTags applies the necessary tags after the instance is created. The RunInstances request made by AWS CloudFormation doesn't support the tags, but the API does support the tags." Please refer to [1] for more information on the same.
So, the workaround for this issue is using "AWS::EC2::LaunchTemplate" resource for EC2 Instance and specify the required Tags on the Volume using "TagSpecification" property in "AWS::EC2::LaunchTemplate" resource. Please refer [2][3] for more information.
We can specify the required Tags for the resources as below.
Instance:
Type: 'AWS::EC2::Instance'
Properties:
LaunchTemplate:
LaunchTemplateId: !Ref RequiredTagsLaunchTemplate
Version: 1
InstanceType: r4.xlarge
.
.
RequiredTagsLaunchTemplate:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
LaunchTemplateData:
TagSpecifications:
- ResourceType: Volume
Tags:
- Key: Env
Value: Dev
References:
[1] https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-ec2-iam-runinstances/
[2] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-launchtemplate.html
[3] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-tagspecification.html
I hope this information will be useful for somebody.
Alex
Relevant content
- asked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 5 months ago
Thank you for your very informative answer!
I included Launch Template Resource to resolve the issue but am still getting the same error. I tried launching the stack with AWS ClI, hoping that I would get a more descriptive output, but no luck. Any idea how to address that?