I have the following policy, however using these policy users can still create resrouces with this tag, however they just will have all access denied to the resource with this policy. Is there a way to deny EC2 creation based on a tag?
{
"'Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor@"
"Effect": "Deny"
"Action": [
"ec2:*"
],
"Resource": [
"arn:aws: ec2:*:*: instance/*"
],
"Condition": {
"StringEquals": {
"aws: ResourceTag/Environment": "test"
}
}
}
]
}
2
Answers
You can try this:
You should use the RequestTag condition key:
The following IAM policy denies users to create a specific tag "Environment" with values "test" when launching new EC2 instances:
RequestTag condition key
ResourceTag condition key
Hope it helps.
Useful Resources: