UNPKG

2.42 kBTypeScriptView Raw
1/**
2 * Possible values for a resource's Removal Policy
3 *
4 * The removal policy controls what happens to the resource if it stops being
5 * managed by CloudFormation. This can happen in one of three situations:
6 *
7 * - The resource is removed from the template, so CloudFormation stops managing it;
8 * - A change to the resource is made that requires it to be replaced, so CloudFormation stops
9 * managing it;
10 * - The stack is deleted, so CloudFormation stops managing all resources in it.
11 *
12 * The Removal Policy applies to all above cases.
13 *
14 * Many stateful resources in the AWS Construct Library will accept a
15 * `removalPolicy` as a property, typically defaulting it to `RETAIN`.
16 *
17 * If the AWS Construct Library resource does not accept a `removalPolicy`
18 * argument, you can always configure it by using the escape hatch mechanism,
19 * as shown in the following example:
20 *
21 * ```ts
22 * declare const bucket: s3.Bucket;
23 *
24 * const cfnBucket = bucket.node.findChild('Resource') as CfnResource;
25 * cfnBucket.applyRemovalPolicy(RemovalPolicy.DESTROY);
26 * ```
27 */
28export declare enum RemovalPolicy {
29 /**
30 * This is the default removal policy. It means that when the resource is
31 * removed from the app, it will be physically destroyed.
32 */
33 DESTROY = "destroy",
34 /**
35 * This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained
36 * in the account, but orphaned from the stack.
37 */
38 RETAIN = "retain",
39 /**
40 * This retention policy deletes the resource,
41 * but saves a snapshot of its data before deleting,
42 * so that it can be re-created later.
43 * Only available for some stateful resources,
44 * like databases, EFS volumes, etc.
45 *
46 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-options
47 */
48 SNAPSHOT = "snapshot"
49}
50export interface RemovalPolicyOptions {
51 /**
52 * The default policy to apply in case the removal policy is not defined.
53 *
54 * @default - Default value is resource specific. To determine the default value for a resoure,
55 * please consult that specific resource's documentation.
56 */
57 readonly default?: RemovalPolicy;
58 /**
59 * Apply the same deletion policy to the resource's "UpdateReplacePolicy"
60 * @default true
61 */
62 readonly applyToUpdateReplacePolicy?: boolean;
63}