Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(secretsmanager): add grantUpdate method #8600

Merged
merged 7 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-secretsmanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ A secret can set `RemovalPolicy`. If it set to `RETAIN`, that removing a secret
### Grant permission to use the secret to a role

You must grant permission to a resource for that resource to be allowed to
use a secret. This can be achieved with the `Secret.grantRead` and/or
`Secret.grantWrite` method, depending on your need:
use a secret. This can be achieved with the `Secret.grantRead` and/or `Secret.grantUpdate`
method, depending on your need:

```ts
const role = new iam.Role(stack, 'SomeRole', { assumedBy: new iam.AccountRootPrincipal() });
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-secretsmanager/lib/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface ISecret extends IResource {
grantRead(grantee: iam.IGrantable, versionStages?: string[]): iam.Grant;

/**
* Grants writing the secret value to some role.
* Grants writing and updating the secret value to some role.
*
* @param grantee the principal being granted permission.
*/
Expand Down Expand Up @@ -166,7 +166,7 @@ abstract class SecretBase extends Resource implements ISecret {
// See https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_identity-based-policies.html
const result = iam.Grant.addToPrincipal({
grantee,
actions: ['secretsmanager:PutSecretValue'],
actions: ['secretsmanager:PutSecretValue', 'secretsmanager:UpdateSecret'],
resourceArns: [this.secretArn],
scope: this,
});
Expand Down
10 changes: 8 additions & 2 deletions packages/@aws-cdk/aws-secretsmanager/test/test.secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ export = {
PolicyDocument: {
Version: '2012-10-17',
Statement: [{
Action: 'secretsmanager:PutSecretValue',
Action: [
'secretsmanager:PutSecretValue',
'secretsmanager:UpdateSecret',
],
Effect: 'Allow',
Resource: { Ref: 'SecretA720EF05' },
}],
Expand All @@ -369,7 +372,10 @@ export = {
PolicyDocument: {
Version: '2012-10-17',
Statement: [{
Action: 'secretsmanager:PutSecretValue',
Action: [
'secretsmanager:PutSecretValue',
'secretsmanager:UpdateSecret',
],
Effect: 'Allow',
Resource: { Ref: 'SecretA720EF05' },
}],
Expand Down