I have few ec2 snapshots with tags as key ce and value ae-12 . I want to allow the role to perform action of ec2:CopySnapshot on the snapshots containing the above mentioned tags only.
I’m using the below policy but it doesn’t work:
{
"Sid": "snapshare",
"Effect": "Allow",
"Action": [
"ec2:CopySnapshot"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/ce": "ae-12"
}
}
}
I also tried "aws:ResourceTag/ce": "yes" in the condition block but it fail too.
Can anyone help me how to tackle this via IAM policy?
2
Answers
Please try the below policy, the following example policy allows principals to copy snapshots only if the new snapshot is created with a tag key of
ce
and a tag value ofae-12
(ce=ae-12
):Hope it helps.
Several things to consider:
https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonec2.html
If you want to block
use
and negative condition
Unfortunately you can limit Condition to Tag Key only for this action.