Skip to content

Commit

Permalink
chore(sns): kms key is not deleted in integ.sns.ts (#29664)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes #29663

### Reason for this change

kms key created within integ test remains after integ test.

### Description of changes

Added "pendingWindow" and "removalPolicy" to kms resource.



```ts
    const key = new Key(this, 'CustomKey', {
      pendingWindow: Duration.days(7),
      removalPolicy: RemovalPolicy.DESTROY,
    });
```

### Description of how you validated changes

I confirmed with integ test that it works as expected.

### Checklist
- [ ] 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*
  • Loading branch information
jun1-t authored Apr 1, 2024
1 parent 99e9589 commit 49ae449
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
}
],
"Version": "2012-10-17"
}
},
"PendingWindowInDays": 7
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"MyTopic86869434": {
"Type": "AWS::SNS::Topic",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Key } from 'aws-cdk-lib/aws-kms';
import { App, Stack, StackProps } from 'aws-cdk-lib';
import { App, Stack, StackProps, RemovalPolicy, Duration } from 'aws-cdk-lib';
import { LoggingProtocol, Topic } from 'aws-cdk-lib/aws-sns';
import { ManagedPolicy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';

class SNSInteg extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
super(scope, id, props);

const key = new Key(this, 'CustomKey');
const key = new Key(this, 'CustomKey', {
pendingWindow: Duration.days(7),
removalPolicy: RemovalPolicy.DESTROY,
});

const topic = new Topic(this, 'MyTopic', {
topicName: 'fooTopic',
Expand Down

0 comments on commit 49ae449

Please sign in to comment.