Based on aws/aws-cdk-rfcs#72 (comment)
Documentation : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html
echo "@gplassard:registry=https://npm.pkg.github.com" > .npmrc
yarn add -D @gplassard/cdk-cloudformation-extensions// bin/app.ts
import { ApplicationStack } from './lib/ApplicationStack';
import { StackPolicy, StackPoliciesStack } from '@gplassard/cdk-cloudformation-extensions';
const app = new cdk.App();
// create an application stack
const stack = new MyApplicationStack(app, 'ApplicationStack', {
});
// create another stack which will attach stack policies to our applications stacks
new StackPoliciesStack(app, 'StackPolicies', {
stackPoliciesAssignment: [
{
stack: stack,
policy: {
Statement: [
{
Effect: 'Allow',
Action: 'Update:*',
Principal: '*',
Resource: '*',
},
],
}
}
]
});
app.synth();