# Serverless remove with a precious dynamodb table

**URL:** <https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119>\
**Category:** Serverless Framework\
**Created:** [January 16, 2017, 2:40am UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119 "2017-01-16T02:40:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hendry/32/343_2.png) [@hendry](https://forum.serverless.com/u/hendry)\
**Post date:** [January 16, 2017, 2:40am UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119/1 "2017-01-16T02:40:39Z")

</div>

I noticed on a `sls remove` my dynamodb table with data inside gets nuked without warning.

```
~/tmp/sls-reduced$ serverless remove
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
...........
Serverless: Stack removal finished...

```

[https://s.natalian.org/2017-01-16/serverless.yml](https://s.natalian.org/2017-01-16/serverless.yml)

So now I am worried that someone who I work with might tear down the table with production values accidentally and cause a LOT of headaches.

So does anyone have any experience or advice for me to make sure this isn’t a problem?

AWS Data Pipeline? Always have a backup in S3?  
Don’t mention DynamoDB tables in Resources?

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [January 16, 2017, 5:36am UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119/2 "2017-01-16T05:36:11Z")

</div>

@hendry you can set a deletion policy when you create the table

```auto
MyTable:
  Type: AWS::DynamoDB::Table
  DeletionPolicy: Retain
  Properties:
    ...

```

This will prevent it from being deleted when you remove your serverles project. Note, that if you do this and want to re-create a dev environment you’ll have delete the table manually after removal.

---

<div class="post-metadata">

**Author:** ![hendry](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hendry/32/343_2.png) [@hendry](https://forum.serverless.com/u/hendry)\
**Post date:** [January 16, 2017, 6:34am UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119/3 "2017-01-16T06:34:32Z")

</div>

Oh, will it fail to create if it sees an existing table with the name it wants?

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [January 16, 2017, 7:08am UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119/4 "2017-01-16T07:08:25Z")

</div>

That’s right @hendry. But it stops you deleting production data so it’s a win :).

If you don’t like that, you could use Serverless Variables to only set it to Retain on production using [Reference Variables in Javascript Files](https://serverless.com/framework/docs/providers/aws/guide/variables#reference-variables-in-javascript-files).

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [January 21, 2017, 11:39pm UTC](https://forum.serverless.com/t/serverless-remove-with-a-precious-dynamodb-table/1119/5 "2017-01-21T23:39:27Z")

</div>

The other option is to manage your DDB Tables in a separate stack to your Serverless service (This sounds like what you want).

You could even use Serverless for this separate stack - just create a `serverless.yml` without any function definitions, and just use the `resources` section to define your DDB table (all thanks to a PR from @johncmckim).
