Skip to content

Latest commit

 

History

History
851 lines (510 loc) · 28.4 KB

API.md

File metadata and controls

851 lines (510 loc) · 28.4 KB

API Reference

Constructs

SelfDestruct

Initializers

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.

scopeRequired
  • Type: aws-cdk-lib.Stack

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

isConstruct
import { SelfDestruct } from 'cdk-self-destruct'

SelfDestruct.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


Structs

AdditionalCleanupOptions

Initializer

import { AdditionalCleanupOptions } from 'cdk-self-destruct'

const additionalCleanupOptions: AdditionalCleanupOptions = { ... }

Properties

Name Type Description
cleanupLambdaLogGroups boolean Whether to destroy all cloudwatch log groups linked to aws lambda functions.

cleanupLambdaLogGroupsRequired
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>.


ByResourceOptions

Initializer

import { ByResourceOptions } from 'cdk-self-destruct'

const byResourceOptions: ByResourceOptions = { ... }

Properties

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.

resourcesToDestroyOptional
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"
resourcesToRetainOptional
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"

CommonOptions

Initializer

import { CommonOptions } from 'cdk-self-destruct'

const commonOptions: CommonOptions = { ... }

Properties

Name Type Description
enabled boolean Whether the resource's removal policy should be set to DESTROY.

enabledRequired
public readonly enabled: boolean;
  • Type: boolean

Whether the resource's removal policy should be set to DESTROY.


DefaultBehavior

Initializer

import { DefaultBehavior } from 'cdk-self-destruct'

const defaultBehavior: DefaultBehavior = { ... }

Properties

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.

destoryAllResourcesRequired
public readonly destoryAllResources: boolean;
  • Type: boolean

Whether to set the removal policy of all resources that are not additionally specified to DESTROY.


purgeResourceDependenciesRequired
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.


performAllAdditionalCleanupOptional
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.


FunctionUrlConfig

Initializer

import { FunctionUrlConfig } from 'cdk-self-destruct'

const functionUrlConfig: FunctionUrlConfig = { ... }

Properties

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.

enabledRequired
public readonly enabled: boolean;
  • Type: boolean

Whether to enable the function url for the stack deletion lambda.


cloudformationOutputOptional
public readonly cloudformationOutput: FunctionUrlOutputProps;

Options to add a cloudformation output to the stack.


optionsOptional
public readonly options: FunctionUrlOptions;
  • Type: aws-cdk-lib.aws_lambda.FunctionUrlOptions

Options to configure the function url.

Can be used to add authentication.


FunctionUrlOutputProps

Initializer

import { FunctionUrlOutputProps } from 'cdk-self-destruct'

const functionUrlOutputProps: FunctionUrlOutputProps = { ... }

Properties

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.

conditionOptional
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.


descriptionOptional
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.


exportNameOptional
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).


S3Options

Initializer

import { S3Options } from 'cdk-self-destruct'

const s3Options: S3Options = { ... }

Properties

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.

enabledRequired
public readonly enabled: boolean;
  • Type: boolean

Whether the resource's removal policy should be set to DESTROY.


purgeNonEmptyBucketsRequired
public readonly purgeNonEmptyBuckets: boolean;
  • Type: boolean

Purge all objects from the bucket before deleting it.

This is mandatory if the bucket is not empty.


ScheduledTriggerOptions

Initializer

import { ScheduledTriggerOptions } from 'cdk-self-destruct'

const scheduledTriggerOptions: ScheduledTriggerOptions = { ... }

Properties

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.

enabledRequired
public readonly enabled: boolean;
  • Type: boolean

afterDurationOptional
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)
atTimestampOptional
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()

SelfDestructProps

Initializer

import { SelfDestructProps } from 'cdk-self-destruct'

const selfDestructProps: SelfDestructProps = { ... }

Properties

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.

defaultBehaviorRequired
public readonly defaultBehavior: DefaultBehavior;

Options to configure if resources should be destroyed by default.


triggerRequired
public readonly trigger: TriggerOptions;

Options to configure the trigger of the stack destruction.


additionalCleanupOptional
public readonly additionalCleanup: AdditionalCleanupOptions;

Additional cleanup for resources not specified in the cloudformation template.


byResourceOptional
public readonly byResource: ByResourceOptions;

Destroy/Retain resources by resource type.


s3BucketsOptional
public readonly s3Buckets: S3Options;

Options to configure the s3 bucket destruction.


stepFunctionsOptional
public readonly stepFunctions: StepFunctionsOptions;

Options to configure the step functions destruction.


StepFunctionsOptions

Initializer

import { StepFunctionsOptions } from 'cdk-self-destruct'

const stepFunctionsOptions: StepFunctionsOptions = { ... }

Properties

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.

enabledRequired
public readonly enabled: boolean;
  • Type: boolean

Whether the resource's removal policy should be set to DESTROY.


cancelRunningExecutionsRequired
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.


TriggerOptions

Initializer

import { TriggerOptions } from 'cdk-self-destruct'

const triggerOptions: TriggerOptions = { ... }

Properties

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.

addFunctionUrlOptional
public readonly addFunctionUrl: FunctionUrlConfig;

Use the lambda's function url to trigger the stack deletion.

This will add an output called SelfDestructFunctionUrl to the stack.


scheduledOptional
public readonly scheduled: ScheduledTriggerOptions;

Create an eventbridge schedule to trigger the stack deletion.


Classes

SelfDestructAspect

  • Implements: aws-cdk-lib.IAspect

Initializers

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.

scopeRequired
  • Type: aws-cdk-lib.Stack

propsRequired

Methods

Name Description
visit All aspects can visit an IConstruct.

visit
public visit(node: IConstruct): void

All aspects can visit an IConstruct.

nodeRequired
  • Type: constructs.IConstruct

Properties

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.

bucketsRequired
public readonly buckets: CfnBucket[];
  • Type: aws-cdk-lib.aws_s3.CfnBucket[]

lambdaFunctionsRequired
public readonly lambdaFunctions: CfnFunction[];
  • Type: aws-cdk-lib.aws_lambda.CfnFunction[]

scopeRequired
public readonly scope: Stack;
  • Type: aws-cdk-lib.Stack

settingsRequired
public readonly settings: SelfDestructProps;

stateMachinesRequired
public readonly stateMachines: CfnStateMachine[];
  • Type: aws-cdk-lib.aws_stepfunctions.CfnStateMachine[]

destructionHandlerRequired
public readonly destructionHandler: NodejsFunction;
  • Type: aws-cdk-lib.aws_lambda_nodejs.NodejsFunction