Skip to content
Snippets Groups Projects
Commit d14c5462 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add deletion policy

parent 74d57872
No related branches found
No related tags found
1 merge request!222add deletion policy
import {aws_ssm as ssm, custom_resources as cr, Stack} from 'aws-cdk-lib'; import {
aws_ssm as ssm,
CfnDeletionPolicy,
CfnResource,
custom_resources as cr,
CustomResource,
RemovalPolicy,
Stack,
} from 'aws-cdk-lib';
import {Construct} from 'constructs'; import {Construct} from 'constructs';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
...@@ -89,12 +97,28 @@ export function updateProxy(props: UpdateProxyProps): cr.AwsCustomResource { ...@@ -89,12 +97,28 @@ export function updateProxy(props: UpdateProxyProps): cr.AwsCustomResource {
}, },
}; };
return new cr.AwsCustomResource(props.scope, `${props.id}SnsReverseProxy`, { const customResource = new cr.AwsCustomResource(
onCreate: sdkCall, props.scope,
onDelete: onDeleteSdkCall, `${props.id}SnsReverseProxy`,
onUpdate: sdkCall, {
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ onCreate: sdkCall,
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE, onDelete: onDeleteSdkCall,
}), onUpdate: sdkCall,
}); removalPolicy: RemovalPolicy.RETAIN,
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
}
);
const cfnResource = (
customResource.node.defaultChild as CustomResource | undefined
)?.node.defaultChild as CfnResource | undefined;
// Update deletion policy
if (cfnResource instanceof CfnResource) {
cfnResource.addOverride('DeletionPolicy', CfnDeletionPolicy.DELETE);
}
return customResource;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment