Aws-cdk: cdk destroy doesnt delete the dynamo table created in the stack

Created on 30 Jul 2019  路  4Comments  路  Source: aws/aws-cdk

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • [X ] :beetle: bug report
    • [ ] :rocket: feature request
    • [ ] :books: construct library gap
    • [ ] :phone: security issue or vulnerability => Please see policy
    • [ ] :question: support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a :beetle:bug:beetle:: Please provide the steps to reproduce
    I've a cdk app in typescript that creates a dynamo table, roles, and resolver for graphql. I had one of the variables wrong the deployment failed.
    When i ran cdk destroy i was expected everything in the stack created using the deploy would be deleted but my table was still there. Hence, when i ran deploy again after destroy
    it gave an error that the table was already there

  • What is the expected behavior (or behavior of feature suggested)?
    destroy should also delete the dynamo table

  • What is the motivation / use case for changing the behavior or adding this feature?

  • Please tell us about your environment:

    • CDK CLI Version: 1.2.0
    • Module Version: 1.2.0
    • OS: [all | Windows 10 | OSX Mojave | Ubuntu | etc... ]
    • Language: Typescript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

@aws-cdaws-dynamodb @aws-cdcore closing-soon guidance

Most helpful comment

That is the expected behaviour. You need to set the removalPolicy to DESTROY, while creating the table, the default is:

RETAIN

This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained in the account, but orphaned from the stack.

removalPolicy: RemovalPolicy.DESTROY

same goes for s3 buckets btw

All 4 comments

That is the expected behaviour. You need to set the removalPolicy to DESTROY, while creating the table, the default is:

RETAIN

This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained in the account, but orphaned from the stack.

removalPolicy: RemovalPolicy.DESTROY

same goes for s3 buckets btw

Hi @harmohan-a!

As @jimbo5644535 said, this is because of the default RemovalPolicy is RETAIN, as outlined here in the documentation.

Let us know if you have any other trouble!

thanks guys

Documentation link in the comment above is broken, here's the link again (I just faced the same 'issue' 馃槃).

Was this page helpful?
0 / 5 - 0 ratings