cdk-aspects-removal-policy
Apply RemovalPolicy using aws-cdk aspects.
Install
npm i -D cdk-aspects-removal-policy
Usage
import { App, Aspects, RemovalPolicy } from 'aws-cdk-lib';
import { ApplyRemovalPolicy } from 'cdk-aspects-removal-policy';
import { StatelessStack } from './YourStatelessStack';
import { StatefulStack } from './YourStatefulStack';
const app = new App();
const statefulStack = new StatefulStack(app, 'StatefulStack');
const statelessStack = new StatelessStack(app, 'StatelessStack');
// Apply RemovalPolicy.
Aspects.of(statefulStack).add(new ApplyRemovalPolicy(RemovalPolicy.RETAIN));
Aspects.of(statelessStack).add(new ApplyRemovalPolicy(RemovalPolicy.DESTROY));
app.synth();