AWS::EC2::SecurityGroup - Tagging-OnCreate
Scope of request
AWS::EC2::SecurityGroup - when I have an IAM deny statement to create a security group without a specifig tag (aws:RequestTags), I can create resource via API, but not via CloudFormation.
Expected behavior
When I create a security group with an IAM policy to enforce tagging, I should be able to create the resource through API or CloudFormation the same way. So far :
- Creating through API/GUI works
- Creating through CloudFormation does not work
Suggest specific test cases
Prerequisites
IAM deny policy should be as follow :
- Effect: "Deny"
Action:
- "ec2:CreateSecurityGroup"
Resource:
- "arn:aws:ec2:*:*:security-group/*"
Condition:
"StringNotLike":
"aws:RequestTag/project":
- "?*"
User should use the Administrator Policy.
Test case success
CFN Template should be just creating a SG with the tag "project" set to any value with 1 or more character. When running, the template should be successful.
Test case failure
CFN Template should be just creating a SG with no tag "project" set. When running, the template should be failing because of a lack of rights.
Category
Networking & Content : Security Group
I looked at Cloudtrail and, at least in my case, CloudFormation is creating the resource and then tagging it in a separate operation. It's messing up my whole template because DependsOn doesn't wait for the tags to be created.
Is there any update on this?
Any update? I'm having the same problema here, but using CDK.
Same here, do not deploy tag at creation is really painfull when play with iam tag restriction
Hey everyone! Apologies for the delayed response, but we recently updated AWS::EC2::SecurityGroup to use tag-on-create. That should let you use the same IAM policies to enforce tagging on security groups for both CloudFormation and other EC2 API calls.
I'm going to resolve this issue, but please either reopen it or create a new issue if you need anything else.
Closing this out based on @davidataws 's comment above. Please let us know if the issue resurfaces or if you have questions.