Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'cdk destroy' is not working as intended or I am not understanding it correctly?

Tags:

aws-cdk

Here is my demo stack,

export class HelloCdkStack extends cdk.Stack {
  constructor(parent: cdk.App, id: string, props?: cdk.StackProps) {
    super(parent, id, props);
    new s3.Bucket(this, 'MyFirstBucket', {
      versioned: true,
      encryption: s3.BucketEncryption.KmsManaged,
    });
  }
}

'cdk deploy' creates a new bucket, but when I execute 'cdk destroy' it does not delete the bucket. Am I doing anything wrong?

like image 201
Atish Narlawar Avatar asked Feb 04 '19 16:02

Atish Narlawar


1 Answers

By default, S3 buckets are configured to be 'orphaned' when a stack is deleted. Setting removalPolicy to Destroy will physically destroy the bucket on deletion.

like image 89
Debora Ito Avatar answered Sep 21 '22 05:09

Debora Ito