chef-boneyard / chef-provisioning-aws

AWS driver and resources for Chef that uses the AWS SDK
Apache License 2.0
142 stars 122 forks source link

AWS Tags Issue #555

Open chenhuazhen opened 6 years ago

chenhuazhen commented 6 years ago

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
btm commented 6 years ago

@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?

r4hulgupta commented 6 years ago

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