0

I want to migrate a huge Serverless project, created with the Serverless Framework, from v0.5 to v1 and my biggest concerns are that resources (DynamoDB tables) that were deployed in sls 0.5 version will be deleted or modified if I would try to deploy from sls version v1.

It is known fact that v1 is not compatible with 0.5... So is it possible to migrate 0.5 resources to 1.0 without breaking the cloud formation structure of DynamoDB tables in AWS? In another word: how to migrate 0.5 resources to 1.0 in a safely manner?

Edit: I have full AWS API gateway in front.

Zanon
  • 29,231
  • 20
  • 113
  • 126

2 Answers2

1

Important: Please try this on a non-production environment first.

  1. Don't do an sls remove on the v0.5 project.
  2. Rewrite your API Gateway and Lambda functions in serverless v1.x but don't include the DynamoDB resources. This means v1.x will only deploy API Gateway endpoints and AWS Lambda functions.
  3. In your Lambda handlers, use the same DynamoDB tables as before.
Noel Llevares
  • 15,018
  • 3
  • 57
  • 81
  • 1
    @dashmuh: What if we have lambdas and API Gateways endpoints already created by v0.5 sls? What happens with them if they are recreated with sls 1.0. –  Jul 03 '17 at 13:48
  • @urosjarc In my case, I opted to recreate them since the structure and naming conventions between the two projects are very different. Switching your friendly URLs to point to the new API Gateway URLs is also very quick and easy so it's not a big deal. – Noel Llevares Jul 03 '17 at 15:45
  • 1
    This seems the best way, to redirect old lambda to new lambda on AWS, new lambda would then use old dynamo resources from v0.5. Thank you! –  Jul 04 '17 at 09:31
0

I'd consider looking into blue green deployments. For DynamoDB you can utilize streams to ensure data is in sync. You mentioned server less but it's hard to recommend a solution there without knowing if you're just doing lambda or if you've got an API gateway in front. In those cases you might want to look into stage variables.

Chris White
  • 1,409
  • 8
  • 10
  • Many thanks for that whitepaper. Yes I have full API gateway, does this helps with my solution? –  Jun 30 '17 at 10:12
  • @urosjarc Then you'll want to look at the second link I put, which describes a system that you can point to a specific Lambda alias ( [this SO link also goes into it a bit](https://stackoverflow.com/questions/35472724/how-to-point-apigateway-to-a-specific-lambda-alias) ). This will let you essentially setup a staging version of the API to test with. Note your lambdas may need to be adjusted to handle access to the staging versions of services. – Chris White Jun 30 '17 at 10:27