serverless / template

Compose & provision a collection of Serverless Components
https://serverless.com
Apache License 2.0
10 stars 6 forks source link

Deploying different environments #14

Open veloware opened 4 years ago

veloware commented 4 years ago

I have followed the steps for the serverless.js file that is to allow deployments to separate environments.

The following -

Invoking sls --env=dev will result in state files in .serverless/ being prefixed with the value of your env: Deploy.dev.json, etc. That way you can deploy unlimited environments, add pre/post processing, load whatever .env you need, etc.

Yes, I see the various state files, but when I give my dynamodb table a name in the serverless file, running a deploy for dev, then another deploy for prod will fail with

message: 'Table already exists: posts-table'

Without Serverless components, I could have posts-table-${opt:stage} to create a posts-table-dev and posts-table-prod.

How do I do this with serverless components?

veloware commented 4 years ago

I was able to get this working using the example in the following repo using serverless.js file rather than serverless.yml https://github.com/hoang-innomizetech/sls-website-example/blob/master/serverless.js

Is this the correct approach?