1.9.1 • Published 4 years ago
@neweracode/cdk-deletion-protection v1.9.1
NewEraCode Deletion Protection Component
Description
An AWS CDK construct that protects the stack from being deleted or a resource from being deleted during update or deployment.
Usage
Install
$ npm i @neweracode/cdk-deletion-protection
Import
NodeJS
const cdp = require('@neweracode/cdk-deletion-protection');
const deletionProtection = new cdp.CDKDeletionProtection(....)
TypeScript / Babel
import { CDKDeletionProtection } from '@neweracode/cdk-deletion-protection';
Example:
import { UserPool, CfnUserPool } from '@aws-cdk/aws-cognito';
import { CDKDeletionProtection } from '@neweracode/cdk-deletion-protection';
const deletionProtection = new CDKDeletionProtection(this, 'ProtectionPolicies', {
resourceDeletionPolicy: "RETAIN",
terminationProtection: true,
});
// enable stack termination deletion protection:
deletionProtection.setStackTerminationProtection(this.stackName);
// protect a Cognito User Pool from getting deleted on update:
const userPool = new UserPool(this, 'cdkUserPool', {...});
const cfnUserPool = userPool.node.defaultChild as CfnUserPool;
deletionProtection.setResourcePolicy(cfnUserPool);