KMS: Key not granting permissions to admins anymore
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
Previously with CDK 2.133, we were able to define additional IAM user ARNs for reference and adding them to a Key Admins array. They ended up in the key policy as expected.
```
var admins = this._platConfig.UploadsBucket.Admins.Select(u => User.FromUserArn(this, u, u));
var keyName = $"appuploads-key";
var uploadsKey = new Key(this, keyName, new KeyProps
{
Alias = keyName,
Description = $"appuploads key.",
Enabled = true,
Admins = admins.ToArray()
});
```
Now with 2.159.1 (build c66f4e3) it appears to ignore the array thus removing the previously defined users in the key policy. Even though the admins IEnumerable has IUser objects.
```
[~] AWS::KMS::Key appuploads-key appuploadskeyC9108645
└─ [~] KeyPolicy
└─ [~] .Statement:
└─ @@ -6,28 +6,5 @@
[ ] "AWS": "arn:aws:iam::ACCOUNTID:root"
[ ] },
[ ] "Resource": "*"
[-] },
[-] {
[-] "Action": [
[-] "kms:CancelKeyDeletion",
[-] "kms:Create*",
[-] "kms:Delete*",
[-] "kms:Describe*",
[-] "kms:Disable*",
[-] "kms:Enable*",
[-] "kms:Get*",
[-] "kms:List*",
[-] "kms:Put*",
[-] "kms:Revoke*",
[-] "kms:ScheduleKeyDeletion",
[-] "kms:TagResource",
[-] "kms:UntagResource",
[-] "kms:Update*"
[-] ],
[-] "Effect": "Allow",
[-] "Principal": {
[-] "AWS": "arn:aws:iam::ACCOUNTID:user/old.user"
[-] },
[-] "Resource": "*"
[ ] }
[ ] ]
```
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Version
1.133
### Expected Behavior
The referenced IUsers added to Key.Admins array end up in key policy.
### Current Behavior
Referenced IUsers removed from key policy.
### Reproduction Steps
1. Update CDK CLI to 2.159.
2. cdk diff existing stack with KMS Key with additional IAM users as Admins.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.159.1 (build c66f4e3)
### Framework Version
_No response_
### Node.js Version
v22.3.0
### OS
Windows 11 23H2
### Language
.NET
### Language Version
C# 10
### Other information
_No response_
Contributor guide
Research direction
Start with the KMS Key and KeyProps Admins entry point, then reproduce the issue using cdk diff with the reported CDK CLI version. Compare the generated KeyPolicy with the expected policy and verify that referenced IUser administrators are present in the key policy when the fix is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, csharp
- Domain
- cloud, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100