chef-provisioning-aws icon indicating copy to clipboard operation
chef-provisioning-aws copied to clipboard

AWS Tags Issue

Open chenhuazhen opened this issue 7 years ago • 2 comments

Run the following

aws_subnet "CSS-BETA-DMZ-Subnet-B" do
  vpc "VPC1"
  cidr_block "10.140.16.0/24"
  aws_tags :chef_type => "ABCDEFG"
end

Got the following error:

[2017-11-17T15:03:28-05:00] FATAL: Aws::EC2::Errors::InvalidParameterValue: aws_subnet[CSS-BETA-DMZ-Subnet-B] (subnet-9
b6a5dfe) (fan-provisioning::css-prod-subnet line 4) had an error: Aws::EC2::Errors::InvalidParameterValue: Value ( aws:
cloudformation:logical-id ) for parameter key is invalid. Tag keys starting with 'aws:' are reserved for internal use

chenhuazhen avatar Nov 17 '17 20:11 chenhuazhen

@chenhuazhen what version of chef-provisioning-aws are you using? Is it a version that comes in a ChefDK package? If so, what version of ChefDK are you using?

btm avatar Nov 22 '17 21:11 btm

I think I have seen this error when you try to work on AWS CloudFormation created resources. Since you just specified :chef_type => "ABCDEFG" it would go and try to delete the rest of the tags, including the ones created by CloudFormation (tag key format is aws:cloudformation:...). But you cannot delete those tags as those are managed by AWS and they won't let you delete those tags. That's where the tagger fails with this mentioned error.

One solution will be to ignore aws managed tags and will probably work with the below change:

Just need to add few more lines to delete keys starting with aws below this line: https://github.com/chef/chef-provisioning-aws/blob/44f819583848bcd381401b498f92ca2c4ad27c1e/lib/chef/provisioning/aws_driver/aws_tagger.rb#L34

r4hulgupta avatar Mar 09 '18 22:03 r4hulgupta