Last active
February 5, 2026 16:04
-
-
Save atheiman/68695e7996fc6ff8fc05c0601daa079c to your computer and use it in GitHub Desktop.
IAM policy example with "dual resource requirement". `kms:CreateAlias` action creates an alias (untaggable) referencing a key (taggable). Breaking alias resource permission into two statements `AllowAllOnTaggedKeys` and `AllowAllOnAliasResource` restricts access to keys w/ the required tag but any alias (b/c untaggable).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "AllowCreateKeyWithTagInRequest", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "kms:CreateKey" | |
| ], | |
| "Resource": "*", | |
| "Condition": { | |
| "StringEquals": { | |
| "aws:RequestTag/owner": "austin" | |
| } | |
| } | |
| }, | |
| { | |
| "Sid": "AllowAllOnTaggedKeys", | |
| "Effect": "Allow", | |
| "Action": "kms:*", | |
| "Resource": "arn:*:kms:*:*:key/*", | |
| "Condition": { | |
| "StringEquals": { | |
| "aws:ResourceTag/owner": "austin" | |
| } | |
| } | |
| }, | |
| { | |
| "Sid": "AllowAllOnAliasResource", | |
| "Effect": "Allow", | |
| "Action": "kms:*", | |
| "Resource": "arn:*:kms:*:*:alias/austin/*" | |
| }, | |
| { | |
| "Sid": "DenySettingUnauthorizedTagValue", | |
| "Effect": "Deny", | |
| "Action": [ | |
| "kms:TagResource" | |
| ], | |
| "Resource": "*", | |
| "Condition": { | |
| "StringNotEquals": { | |
| "aws:RequestTag/owner": "austin" | |
| } | |
| } | |
| }, | |
| { | |
| "Sid": "DenyRemovingTag", | |
| "Effect": "Deny", | |
| "Action": [ | |
| "kms:UntagResource" | |
| ], | |
| "Resource": "*", | |
| "Condition": { | |
| "ForAnyValue:StringEquals": { | |
| "aws:TagKeys": "owner" | |
| } | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment