Skip to content

Commit ffd3d2d

Browse files
authored
docs: explain procedure for rotating a SecretsManager Secret (#20989)
CloudFormation will not automatically check all Secrets for their values, so it is up to the user to incude a change in the resource that uses a Secret, so that CloudFormation will re-read the value. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 52b7019 commit ffd3d2d

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ export interface GitHubSourceActionProps extends codepipeline.CommonActionProps
6767
* const oauth = cdk.SecretValue.secretsManager('my-github-token');
6868
* new GitHubSource(this, 'GitHubAction', { oauthToken: oauth, ... });
6969
*
70+
* If you rotate the value in the Secret, you must also change at least one property
71+
* of the CodePipeline to force CloudFormation to re-read the secret.
72+
*
7073
* The GitHub Personal Access Token should have these scopes:
7174
*
7275
* * **repo** - to read the repository

packages/@aws-cdk/core/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ exposed where they shouldn't be. If you try to use a `SecretValue` in a
276276
different location, an error about unsafe secret usage will be thrown at
277277
synthesis time.
278278

279+
If you rotate the secret's value in Secrets Manager, you must also change at
280+
least one property on the resource where you are using the secret, to force
281+
CloudFormation to re-read the secret.
282+
283+
`SecretValue.ssmSecure()` is only supported for a limited set of resources.
284+
[Click here for a list of supported resources and properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#template-parameters-dynamic-patterns-resources).
285+
279286
## ARN manipulation
280287

281288
Sometimes you will need to put together or pick apart Amazon Resource Names

packages/@aws-cdk/core/lib/secret-value.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export class SecretValue extends Intrinsic {
7676

7777
/**
7878
* Creates a `SecretValue` with a value which is dynamically loaded from AWS Secrets Manager.
79+
*
80+
* If you rotate the value in the Secret, you must also change at least one property
81+
* on the resource where you are using the secret, to force CloudFormation to re-read the secret.
82+
*
7983
* @param secretId The ID or ARN of the secret
8084
* @param options Options
8185
*/
@@ -107,6 +111,10 @@ export class SecretValue extends Intrinsic {
107111
/**
108112
* Use a secret value stored from a Systems Manager (SSM) parameter.
109113
*
114+
* This secret source in only supported in a limited set of resources and
115+
* properties. [Click here for the list of supported
116+
* properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#template-parameters-dynamic-patterns-resources).
117+
*
110118
* @param parameterName The name of the parameter in the Systems Manager
111119
* Parameter Store. The parameter name is case-sensitive.
112120
*

packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline-source.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export abstract class CodePipelineSource extends Step implements ICodePipelineAc
3434
* Authentication will be done by a secret called `github-token` in AWS
3535
* Secrets Manager (unless specified otherwise).
3636
*
37+
* If you rotate the value in the Secret, you must also change at least one property
38+
* on the Pipeline, to force CloudFormation to re-read the secret.
39+
*
3740
* The token should have these permissions:
3841
*
3942
* * **repo** - to read the repository

packages/aws-cdk-lib/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@ exposed where they shouldn't be. If you try to use a `SecretValue` in a
307307
different location, an error about unsafe secret usage will be thrown at
308308
synthesis time.
309309

310+
If you rotate the secret's value in Secrets Manager, you must also change at
311+
least one property on the resource where you are using the secret, to force
312+
CloudFormation to re-read the secret.
313+
314+
`SecretValue.ssmSecure()` is only supported for a limited set of resources.
315+
[Click here for a list of supported resources and properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#template-parameters-dynamic-patterns-resources).
316+
310317
## ARN manipulation
311318

312319
Sometimes you will need to put together or pick apart Amazon Resource Names

0 commit comments

Comments
 (0)