Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to continue deploy if DynamoDb table already exists

I'd like to continue the deployment (or force) even if a resource already exists.

Atm I got this error:

Serverless Error ---------------------------------------

     An error occurred while provisioning your stack: AvailableDynamoDbTable
     - Available already exists.
like image 707
Marckaraujo Avatar asked Jan 12 '17 18:01

Marckaraujo


3 Answers

This question is fairly old, but still shows up in the top 5 results in Google, so here is a bit of an insight: It's a good idea to split up your serverless stack into multiple services, each having its own serverless.yml file. One for your API and lambdas, one for your DynamoDB. This way you can deal with them separately and update your lambdas without touching your DB. Here is a great guide on that:

  1. https://serverless-stack.com/chapters/organizing-serverless-projects.html
  2. https://serverless-stack.com/chapters/dynamodb-as-a-serverless-service.html
  3. https://serverless-stack.com/chapters/deploying-multiple-services-in-serverless.html
like image 63
Gábor Pintér Avatar answered Oct 23 '22 10:10

Gábor Pintér


Backup the table and delete it. Restore once deployed.

I had the same issue when I renamed my serverless project and tried to deploy. I had a table tanks that was being used again. It failed with the following

Serverless Error ---------------------------------------

 An error occurred: TanksDynamoDbTable - tanks already exists in stack arn:aws:cloudformation:eu-central-1:592235674655:stack/colossal-dev/105693a8-77af-11e9-8f9e-2a86e4085a59.

I got it solved by making a backup of the tanks table, then deleting it.

  1. Console > DynamoDB
  2. On the left select Backups
  3. Create backup > select Table from the dropdown and give it a name > Create
  4. On the left select Tables
  5. Check on Tanks > Delete

After deleting, one must wait for five minutes because the caches are cleaned periodically and not immediately. After that, I tried serverless deploy and it worked. After this, you will need to restore the backed up database.

  1. On the left select Backups
  2. Check the backed up table > Restore
  3. Type the same name for the table as before, as the new table name.
  4. Restore table Restored database takes some time appear so wait for perhaps five minutes or may be longer.
like image 43
Vishal Desai Avatar answered Oct 23 '22 09:10

Vishal Desai


Its not possible atm with [email protected].

I just open an issue on github: https://github.com/serverless/serverless/issues/3183

Please, everyone that need this feature, join this discussion.

I will update here with news.

like image 3
Marckaraujo Avatar answered Oct 23 '22 09:10

Marckaraujo