sbstjn / serverless-dynamodb-autoscaling

Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.
https://sbstjn.com/serverless-dynamodb-auto-scaling-with-cloudformation.html
MIT License
148 stars 27 forks source link

dynamodb already exists #16

Closed sjernigan closed 7 years ago

sjernigan commented 7 years ago

FYI: I'm sure I could kill and redeploy my stack but adding this to an existing stack gives

An error occurred while provisioning your stack: myserviceAutoScalingTargetReadParticipantsDynamoDbTabledev - table/myservice_participants-dev|dynamodb:table:ReadCapacityUnits|dynamodb already exists.

sbstjn commented 7 years ago

Do you create your DynamoDB table with the same CloudFormation stack or does it already exists?

sjernigan commented 7 years ago

I created it with a CloudFormation stack and subsequently added this to that same stack.

mrtnzlml commented 7 years ago

Hi, I have exactly the same problem. Everything has been created using serverless (not manually) and I only updated this plugin from ^0.3.0 to the ^0.5.1. I also deleted the DynamoDB table but the error is still here (?).

An error occurred while provisioning your stack: chatbotAutoScalingTargetReadconversationsTablestaging - table/conversationsTable-staging|dynamodb:table:ReadCapacityUnits|dynamodb already exists in stack arn:aws:cloudformation:eu-west-1:00000:stack/chatbot-staging/...

Can you help me with this problem, please? 🙂

sbstjn commented 7 years ago

I just wanted to ask if you had already enabled Auto Scaling using the AWS Console and maybe a target gets not removed when you disable it. But you said you created everything using serverless :(

Can you provide steps or a sample configuration to reproduce the issue? Then I will definitely have a look into it.

I have successfully deployed complete new stacks with the plugin, as well as enabled Auto Scaling to DynamoDB tables in production. :(

sbstjn commented 7 years ago

I have an idea what could cause this.

I renamed some resources in the stack to ensure unique names/resources and so there might still exists the old AutoScalingTarget with the old resource identifier and this could collide with the new resource. 😢

mrtnzlml commented 7 years ago

Steps to reproduce:

I have an idea what could cause this...

Your idea sounds right to me.

So far we have reverted back to the v0.3.0 (exact version). Also, I am ok with this change but I would welcome some info how to use newest versions without redeploying the whole stack... :)

sbstjn commented 7 years ago

The releases between 0.3 and 0.5 are mostly internal changes and offer no improvements regarding the Auto Scaling, so it should be fine if you just stay on 0.3 …

One solution would be to add an useOldNamingSchema property to the custom configuration and switch the naming schemas. But it would be very happy to avoid this ;)

Maybe it's possible for you to remove the "old" AutoScalingTarget using the AWS API/CLI/Console and then just run the deployment again.

sbstjn commented 7 years ago

You could deploy your stack without any Auto Scaling, this should throw all resources away. After that just redeploy your stack with the most recent plugin version and you should be fine!

lucasklaassen commented 7 years ago

What about supporting multi-region deployments within the same AWS account? Would it be possible to add the region to auto scaling user role?

<projectName>-DynamoDBAutoscaleRole-<DatabaseResourceName>-staging-<Region>

sbstjn commented 7 years ago

Multi-Region support will be added in the next version. See #21

sbstjn commented 7 years ago

I just pushed v0.6.0 to NPM with an updated naming schema @lucasklaassen and added a paragraph about breaking changes to the README.md.

mrtnzlml commented 7 years ago

@sbstjn Thanks, I can confirm that your migration guide works. Now let's upgrade it again to fix another bug: https://github.com/sbstjn/serverless-dynamodb-autoscaling/pull/22 😄

sbstjn commented 7 years ago

22 is merged, hopefully everything is fine. I need some tests to test the generated CF resources. You are more than welcome to provide some ;)

PrasoonJain97 commented 4 years ago

FYI: I'm sure I could kill and redeploy my stack but adding this to an existing stack gives

An error occurred while provisioning your stack: myserviceAutoScalingTargetReadParticipantsDynamoDbTabledev - table/myservice_participants-dev|dynamodb:table:ReadCapacityUnits|dynamodb already exists.

HI, Can you tell me what exactly this error means ? Does this means dynamodb table already exists or something else ?