Show / Hide Table of Contents

Interface IRemovalPolicyProps

Properties for applying a removal policy.

Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IRemovalPolicyProps
Syntax (vb)
Public Interface IRemovalPolicyProps
Remarks

ExampleMetadata: infused

Examples
Construct scope;
            Construct parent;
            CfnBucket bucket;


            // Apply DESTROY policy to all resources in a scope
            RemovalPolicies.Of(scope).Destroy();

            // Apply RETAIN policy to all resources in a scope
            RemovalPolicies.Of(scope).Retain();

            // Apply SNAPSHOT policy to all resources in a scope
            RemovalPolicies.Of(scope).Snapshot();

            // Apply RETAIN_ON_UPDATE_OR_DELETE policy to all resources in a scope
            RemovalPolicies.Of(scope).RetainOnUpdateOrDelete();

            // Apply RETAIN policy only to specific resource types
            RemovalPolicies.Of(parent).Retain(new RemovalPolicyProps {
                ApplyToResourceTypes = new [] { "AWS::DynamoDB::Table", bucket.CfnResourceType, CfnDBInstance.CFN_RESOURCE_TYPE_NAME }
            });

            // Apply SNAPSHOT policy excluding specific resource types
            RemovalPolicies.Of(scope).Snapshot(new RemovalPolicyProps {
                ExcludeResourceTypes = new [] { "AWS::Test::Resource" }
            });

Synopsis

Properties

ApplyToResourceTypes

Apply the removal policy only to specific resource types.

ExcludeResourceTypes

Exclude specific resource types from the removal policy.

Priority

The priority to use when applying this policy.

Properties

ApplyToResourceTypes

Apply the removal policy only to specific resource types.

string[]? ApplyToResourceTypes { get; }
Property Value

string[]

Remarks

Can be a CloudFormation resource type string (e.g., 'AWS::S3::Bucket').

Default: - apply to all resources

ExcludeResourceTypes

Exclude specific resource types from the removal policy.

string[]? ExcludeResourceTypes { get; }
Property Value

string[]

Remarks

Can be a CloudFormation resource type string (e.g., 'AWS::S3::Bucket').

Default: - no exclusions

Priority

The priority to use when applying this policy.

double? Priority { get; }
Property Value

double?

Remarks

The priority affects only the order in which aspects are applied during synthesis. For RemovalPolicies, the last applied policy will override previous ones.

NOTE: Priority does NOT determine which policy "wins" when there are conflicts. The order of application determines the final policy, with later policies overriding earlier ones.

Default: - AspectPriority.MUTATING

Back to top Generated by DocFX