import { SelfDestruct } from 'cdk-self-destruct'
new SelfDestruct(scope: Stack, id: string, props: SelfDestructProps)
Name | Type | Description |
---|---|---|
scope |
aws-cdk-lib.Stack |
No description. |
id |
string |
No description. |
props |
SelfDestructProps |
No description. |
- Type: aws-cdk-lib.Stack
- Type: string
- Type: SelfDestructProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { SelfDestruct } from 'cdk-self-destruct'
SelfDestruct.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
import { AdditionalCleanupOptions } from 'cdk-self-destruct'
const additionalCleanupOptions: AdditionalCleanupOptions = { ... }
Name | Type | Description |
---|---|---|
cleanupLambdaLogGroups |
boolean |
Whether to destroy all cloudwatch log groups linked to aws lambda functions. |
public readonly cleanupLambdaLogGroups: boolean;
- Type: boolean
Whether to destroy all cloudwatch log groups linked to aws lambda functions.
This does not affect log groups specified in the cloudformation template, only the ones that are automatically created by the lambda service.
It deletes the log groups for all lambda functions in the stack with the format /aws/lambda/<function-name>
.
import { ByResourceOptions } from 'cdk-self-destruct'
const byResourceOptions: ByResourceOptions = { ... }
Name | Type | Description |
---|---|---|
resourcesToDestroy |
string[] |
A list of cloudformation resources that should be destroyed. |
resourcesToRetain |
string[] |
A list of cloudformation resources that should be retained. |
public readonly resourcesToDestroy: string[];
- Type: string[]
A list of cloudformation resources that should be destroyed.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
Example
"AWS::Cognito::UserPool"
public readonly resourcesToRetain: string[];
- Type: string[]
A list of cloudformation resources that should be retained.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
Example
"AWS::Cognito::UserPool"
import { CommonOptions } from 'cdk-self-destruct'
const commonOptions: CommonOptions = { ... }
Name | Type | Description |
---|---|---|
enabled |
boolean |
Whether the resource's removal policy should be set to DESTROY. |
public readonly enabled: boolean;
- Type: boolean
Whether the resource's removal policy should be set to DESTROY.
import { DefaultBehavior } from 'cdk-self-destruct'
const defaultBehavior: DefaultBehavior = { ... }
Name | Type | Description |
---|---|---|
destoryAllResources |
boolean |
Whether to set the removal policy of all resources that are not additionally specified to DESTROY. |
purgeResourceDependencies |
boolean |
Whether to destroy all data that a resource depends on. |
performAllAdditionalCleanup |
boolean |
Whether to destroy additional resources by default that are not automattically removed by cloudformation specified. |
public readonly destoryAllResources: boolean;
- Type: boolean
Whether to set the removal policy of all resources that are not additionally specified to DESTROY.
public readonly purgeResourceDependencies: boolean;
- Type: boolean
Whether to destroy all data that a resource depends on.
For example, if a bucket has objects in it, it cannot be deleted. Running step functions will also prevent the stack from being deleted.
public readonly performAllAdditionalCleanup: boolean;
- Type: boolean
Whether to destroy additional resources by default that are not automattically removed by cloudformation specified.
At this time this only includes cloudwatch log groups linked to aws lambda functions.
import { FunctionUrlConfig } from 'cdk-self-destruct'
const functionUrlConfig: FunctionUrlConfig = { ... }
Name | Type | Description |
---|---|---|
enabled |
boolean |
Whether to enable the function url for the stack deletion lambda. |
cloudformationOutput |
FunctionUrlOutputProps |
Options to add a cloudformation output to the stack. |
options |
aws-cdk-lib.aws_lambda.FunctionUrlOptions |
Options to configure the function url. |
public readonly enabled: boolean;
- Type: boolean
Whether to enable the function url for the stack deletion lambda.
public readonly cloudformationOutput: FunctionUrlOutputProps;
- Type: FunctionUrlOutputProps
Options to add a cloudformation output to the stack.
public readonly options: FunctionUrlOptions;
- Type: aws-cdk-lib.aws_lambda.FunctionUrlOptions
Options to configure the function url.
Can be used to add authentication.
import { FunctionUrlOutputProps } from 'cdk-self-destruct'
const functionUrlOutputProps: FunctionUrlOutputProps = { ... }
Name | Type | Description |
---|---|---|
condition |
aws-cdk-lib.CfnCondition |
A condition to associate with this output value. |
description |
string |
A String type that describes the output value. |
exportName |
string |
The name used to export the value of this output across stacks. |
public readonly condition: CfnCondition;
- Type: aws-cdk-lib.CfnCondition
- Default: No condition is associated with the output.
A condition to associate with this output value.
If the condition evaluates
to false
, this output value will not be included in the stack.
public readonly description: string;
- Type: string
- Default: No description.
A String type that describes the output value.
The description can be a maximum of 4 K in length.
public readonly exportName: string;
- Type: string
- Default: the output is not exported
The name used to export the value of this output across stacks.
To import the value from another stack, use Fn.importValue(exportName)
.
import { S3Options } from 'cdk-self-destruct'
const s3Options: S3Options = { ... }
Name | Type | Description |
---|---|---|
enabled |
boolean |
Whether the resource's removal policy should be set to DESTROY. |
purgeNonEmptyBuckets |
boolean |
Purge all objects from the bucket before deleting it. |
public readonly enabled: boolean;
- Type: boolean
Whether the resource's removal policy should be set to DESTROY.
public readonly purgeNonEmptyBuckets: boolean;
- Type: boolean
Purge all objects from the bucket before deleting it.
This is mandatory if the bucket is not empty.
import { ScheduledTriggerOptions } from 'cdk-self-destruct'
const scheduledTriggerOptions: ScheduledTriggerOptions = { ... }
Name | Type | Description |
---|---|---|
enabled |
boolean |
No description. |
afterDuration |
aws-cdk-lib.Duration |
The duration after starting the deployment after which the stack should be deleted. |
atTimestamp |
number |
The timestamp at which the stack should be deleted. |
public readonly enabled: boolean;
- Type: boolean
public readonly afterDuration: Duration;
- Type: aws-cdk-lib.Duration
The duration after starting the deployment after which the stack should be deleted.
Cannot be used together with atTimestamp
.
Example
Duration.days(1)
public readonly atTimestamp: number;
- Type: number
The timestamp at which the stack should be deleted.
Must be a unix timestamp in milliseconds. Timezone must be UTC
Cannot be used together with afterDuration
.
Example
new Date("2023-01-01T00:00:00Z").getTime()
import { SelfDestructProps } from 'cdk-self-destruct'
const selfDestructProps: SelfDestructProps = { ... }
Name | Type | Description |
---|---|---|
defaultBehavior |
DefaultBehavior |
Options to configure if resources should be destroyed by default. |
trigger |
TriggerOptions |
Options to configure the trigger of the stack destruction. |
additionalCleanup |
AdditionalCleanupOptions |
Additional cleanup for resources not specified in the cloudformation template. |
byResource |
ByResourceOptions |
Destroy/Retain resources by resource type. |
s3Buckets |
S3Options |
Options to configure the s3 bucket destruction. |
stepFunctions |
StepFunctionsOptions |
Options to configure the step functions destruction. |
public readonly defaultBehavior: DefaultBehavior;
- Type: DefaultBehavior
Options to configure if resources should be destroyed by default.
public readonly trigger: TriggerOptions;
- Type: TriggerOptions
Options to configure the trigger of the stack destruction.
public readonly additionalCleanup: AdditionalCleanupOptions;
- Type: AdditionalCleanupOptions
Additional cleanup for resources not specified in the cloudformation template.
public readonly byResource: ByResourceOptions;
- Type: ByResourceOptions
Destroy/Retain resources by resource type.
public readonly s3Buckets: S3Options;
- Type: S3Options
Options to configure the s3 bucket destruction.
public readonly stepFunctions: StepFunctionsOptions;
- Type: StepFunctionsOptions
Options to configure the step functions destruction.
import { StepFunctionsOptions } from 'cdk-self-destruct'
const stepFunctionsOptions: StepFunctionsOptions = { ... }
Name | Type | Description |
---|---|---|
enabled |
boolean |
Whether the resource's removal policy should be set to DESTROY. |
cancelRunningExecutions |
boolean |
Cancel all running executions before deleting the state machine. |
public readonly enabled: boolean;
- Type: boolean
Whether the resource's removal policy should be set to DESTROY.
public readonly cancelRunningExecutions: boolean;
- Type: boolean
Cancel all running executions before deleting the state machine.
Otherwise, the cloudformation stack will fail be waiting until all executions are finished.
import { TriggerOptions } from 'cdk-self-destruct'
const triggerOptions: TriggerOptions = { ... }
Name | Type | Description |
---|---|---|
addFunctionUrl |
FunctionUrlConfig |
Use the lambda's function url to trigger the stack deletion. |
scheduled |
ScheduledTriggerOptions |
Create an eventbridge schedule to trigger the stack deletion. |
public readonly addFunctionUrl: FunctionUrlConfig;
- Type: FunctionUrlConfig
Use the lambda's function url to trigger the stack deletion.
This will add an output called SelfDestructFunctionUrl
to the stack.
public readonly scheduled: ScheduledTriggerOptions;
- Type: ScheduledTriggerOptions
Create an eventbridge schedule to trigger the stack deletion.
- Implements: aws-cdk-lib.IAspect
import { SelfDestructAspect } from 'cdk-self-destruct'
new SelfDestructAspect(scope: Stack, props: SelfDestructProps)
Name | Type | Description |
---|---|---|
scope |
aws-cdk-lib.Stack |
No description. |
props |
SelfDestructProps |
No description. |
- Type: aws-cdk-lib.Stack
- Type: SelfDestructProps
Name | Description |
---|---|
visit |
All aspects can visit an IConstruct. |
public visit(node: IConstruct): void
All aspects can visit an IConstruct.
- Type: constructs.IConstruct
Name | Type | Description |
---|---|---|
buckets |
aws-cdk-lib.aws_s3.CfnBucket[] |
No description. |
lambdaFunctions |
aws-cdk-lib.aws_lambda.CfnFunction[] |
No description. |
scope |
aws-cdk-lib.Stack |
No description. |
settings |
SelfDestructProps |
No description. |
stateMachines |
aws-cdk-lib.aws_stepfunctions.CfnStateMachine[] |
No description. |
destructionHandler |
aws-cdk-lib.aws_lambda_nodejs.NodejsFunction |
No description. |
public readonly buckets: CfnBucket[];
- Type: aws-cdk-lib.aws_s3.CfnBucket[]
public readonly lambdaFunctions: CfnFunction[];
- Type: aws-cdk-lib.aws_lambda.CfnFunction[]
public readonly scope: Stack;
- Type: aws-cdk-lib.Stack
public readonly settings: SelfDestructProps;
- Type: SelfDestructProps
public readonly stateMachines: CfnStateMachine[];
- Type: aws-cdk-lib.aws_stepfunctions.CfnStateMachine[]
public readonly destructionHandler: NodejsFunction;
- Type: aws-cdk-lib.aws_lambda_nodejs.NodejsFunction