forked from ansible-collections/community.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aws_kms_info - Gracefully Handle Keys That Don't Allow kms:GetKeyRota…
…tionStatus API Calls (ansible-collections#199) * Gracefully handle keys that don't allow kms:GetKeyRotationStatus API calls Some AWS KMS keys (e.g. aws/acm) do not allow permissions to call the API kms:GetKeyRotationStatus. As a result, module execution fails, even if the user execuing it has full admin privileges. Example: https://forums.aws.amazon.com/thread.jspa?threadID=312992 * change log fragment * Return None if key rotation status can't be determined Update documentation to reflect this use case. Use helper to track the exception. * Add integration tests
- Loading branch information
1 parent
0185721
commit f7ca37a
Showing
4 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
changelogs/fragments/199-aws_kms_info-key-rotation-status.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bugfixes: | ||
- aws_kms_info - fixes issue where module execution fails because certain AWS KMS keys (e.g. aws/acm) | ||
do not permit the calling the API kms:GetKeyRotationStatus | ||
(example - https://forums.aws.amazon.com/thread.jspa?threadID=312992) | ||
(https://github.com/ansible-collections/community.aws/pull/199) |
This file contains 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
This file contains 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
81 changes: 81 additions & 0 deletions
81
tests/integration/targets/aws_kms/templates/console-policy-no-key-rotation.j2
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"Id": "key-consolepolicy-3", | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "Enable IAM User Permissions", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "arn:aws:iam::{{ aws_caller_info.account }}:root" | ||
}, | ||
"Action": "kms:*", | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "Allow access for Key Administrators", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "{{ aws_caller_info.arn }}" | ||
}, | ||
"Action": [ | ||
"kms:Create*", | ||
"kms:Describe*", | ||
"kms:Enable*", | ||
"kms:List*", | ||
"kms:Put*", | ||
"kms:Update*", | ||
"kms:Revoke*", | ||
"kms:Disable*", | ||
"kms:Get*", | ||
"kms:Delete*", | ||
"kms:TagResource", | ||
"kms:UntagResource", | ||
"kms:ScheduleKeyDeletion", | ||
"kms:CancelKeyDeletion" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "Allow use of the key", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "{{ aws_caller_info.arn }}" | ||
}, | ||
"Action": [ | ||
"kms:Encrypt", | ||
"kms:Decrypt", | ||
"kms:ReEncrypt*", | ||
"kms:GenerateDataKey*", | ||
"kms:DescribeKey" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "Allow attachment of persistent resources", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "{{ aws_caller_info.arn }}" | ||
}, | ||
"Action": [ | ||
"kms:CreateGrant", | ||
"kms:ListGrants", | ||
"kms:RevokeGrant" | ||
], | ||
"Resource": "*", | ||
"Condition": { | ||
"Bool": { | ||
"kms:GrantIsForAWSResource": "true" | ||
} | ||
} | ||
}, | ||
{ | ||
"Sid": "Disable access to key rotation status", | ||
"Effect": "Deny", | ||
"Principal": { | ||
"AWS": "{{ aws_caller_info.arn }}" | ||
}, | ||
"Action": "kms:GetKeyRotationStatus", | ||
"Resource": "*" | ||
} | ||
] | ||
} |