Skip to content

Commit 86d2853

Browse files
authored
feat(kms): add sign and verify related grant methods (#32681)
### Issue # Closes #23185 ### Reason for this change Adds `grant` methods for signing and verifying signatures with KMS ### Description of changes Three new `grant` methods have been added: - `grantSign()`: Adds `'kms:Sign'` to the principal - `grantVerify()`: Adds `'kms:Verify'` to the principal - `grantSignVerify()`: Adds `['kms:Sign', 'kms:Verify']` to the principal ### Description of how you validated changes - Added new unit tests to verify the output of the 3 new `grant` methods - Added a new integ test for `grantSignVerify()` ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent caf2415 commit 86d2853

15 files changed

+995
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/KeyGrantsIntegTestDefaultTestDeployAssert49AF830A.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/KeyGrantsIntegTestDefaultTestDeployAssert49AF830A.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/aws-cdk-kms-grants.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"Resources": {
3+
"Role1ABCC5F0": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"AWS": {
13+
"Fn::Join": [
14+
"",
15+
[
16+
"arn:",
17+
{
18+
"Ref": "AWS::Partition"
19+
},
20+
":iam::",
21+
{
22+
"Ref": "AWS::AccountId"
23+
},
24+
":root"
25+
]
26+
]
27+
}
28+
}
29+
}
30+
],
31+
"Version": "2012-10-17"
32+
}
33+
}
34+
},
35+
"RoleDefaultPolicy5FFB7DAB": {
36+
"Type": "AWS::IAM::Policy",
37+
"Properties": {
38+
"PolicyDocument": {
39+
"Statement": [
40+
{
41+
"Action": [
42+
"kms:Sign",
43+
"kms:Verify"
44+
],
45+
"Effect": "Allow",
46+
"Resource": {
47+
"Fn::GetAtt": [
48+
"MyKey6AB29FA6",
49+
"Arn"
50+
]
51+
}
52+
}
53+
],
54+
"Version": "2012-10-17"
55+
},
56+
"PolicyName": "RoleDefaultPolicy5FFB7DAB",
57+
"Roles": [
58+
{
59+
"Ref": "Role1ABCC5F0"
60+
}
61+
]
62+
}
63+
},
64+
"MyKey6AB29FA6": {
65+
"Type": "AWS::KMS::Key",
66+
"Properties": {
67+
"KeyPolicy": {
68+
"Statement": [
69+
{
70+
"Action": "kms:*",
71+
"Effect": "Allow",
72+
"Principal": {
73+
"AWS": {
74+
"Fn::Join": [
75+
"",
76+
[
77+
"arn:",
78+
{
79+
"Ref": "AWS::Partition"
80+
},
81+
":iam::",
82+
{
83+
"Ref": "AWS::AccountId"
84+
},
85+
":root"
86+
]
87+
]
88+
}
89+
},
90+
"Resource": "*"
91+
}
92+
],
93+
"Version": "2012-10-17"
94+
}
95+
},
96+
"UpdateReplacePolicy": "Delete",
97+
"DeletionPolicy": "Delete"
98+
}
99+
},
100+
"Parameters": {
101+
"BootstrapVersion": {
102+
"Type": "AWS::SSM::Parameter::Value<String>",
103+
"Default": "/cdk-bootstrap/hnb659fds/version",
104+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
105+
}
106+
},
107+
"Rules": {
108+
"CheckBootstrapVersion": {
109+
"Assertions": [
110+
{
111+
"Assert": {
112+
"Fn::Not": [
113+
{
114+
"Fn::Contains": [
115+
[
116+
"1",
117+
"2",
118+
"3",
119+
"4",
120+
"5"
121+
],
122+
{
123+
"Ref": "BootstrapVersion"
124+
}
125+
]
126+
}
127+
]
128+
},
129+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
130+
}
131+
]
132+
}
133+
}
134+
}

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.key-grants.js.snapshot/manifest.json

+125
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)