SEED: Promote to PROD


#1

I am using SEED to automate the deployment of my changes to the source code to dev and to prod. I have deployed to dev and then I click on the Promote button in SEED and I confirm since there are no changes in the environment and I get this error:

Serverless Warning --------------------------------------
 
  A valid file to satisfy the declaration 'file(env.yml):dev,file(env.yml):default' could not be found.
 
Serverless: Invoke deploy
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:moveArtifactsToTemp
Serverless: Invoke aws:deploy:deploy
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (1.52 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...........................
Serverless: Operation failed!
 
  Serverless Error ---------------------------------------
 
  An error occurred: TreatmentLogs - dev-treatmentLogs already exists in stack arn:aws:cloudformation:us-east-1:968256005255:stack/spectrum-treatment-log-api-dev/df7e11d0-f373-11e8-8816-12c395c1242e.
 
  Stack Trace --------------------------------------------
 
ServerlessError: An error occurred: TreatmentLogs - dev-treatmentLogs already exists in stack arn:aws:cloudformation:us-east-1:968256005255:stack/spectrum-treatment-log-api-dev/df7e11d0-f373-11e8-8816-12c395c1242e.
    at provider.request.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:112:33)
From previous event:
    at AwsDeploy.monitorStack (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:26:12)
    at provider.request.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:95:30)
From previous event:
    at AwsDeploy.update (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:95:8)
From previous event:
    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:112:12)
From previous event:
    at AwsDeploy.updateStack (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:106:8)
From previous event:
    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:129:39)
From previous event:
    at Object.aws:deploy:deploy:updateStack [as hook] (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:125:10)
    at BbPromise.reduce (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
    at PluginManager.invoke (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:22)
    at PluginManager.spawn (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:408:17)
    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:95:48)
From previous event:
    at Object.deploy:deploy [as hook] (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:91:10)
    at BbPromise.reduce (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
    at PluginManager.invoke (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:22)
    at PluginManager.run (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:421:17)
    at variables.populateService.then.then (/sls-1.29.2/node_modules/serverless/lib/Serverless.js:157:33)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
From previous event:
    at Serverless.run (/sls-1.29.2/node_modules/serverless/lib/Serverless.js:144:8)
    at serverless.init.then (/sls-1.29.2/node_modules/serverless/bin/serverless:43:50)
    at <anonymous>
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           8.10.0
     Serverless Version:     1.29.2
 

2018/12/01 19:55:48 Error: exec: internal error


====================
🗑 Cleanup
====================

2018/12/01 19:55:48 Post deploy cleanup

I see that the stage is added correctly since SEED is deploying with the correct stage set explicitly through the command line.

Why is it trying to redeploy to dev when I am trying to promote to PROD only???

My confusion comes from this command when promoting to prod:

====================
🚀 Deploy
====================

2018/12/01 19:55:04 Deploying to: prod

$ SLS_DEBUG=* serverless deploy --stage prod --package promote-artifacts --force 

As you can see above SEED runs serverless deploy to prod with the correct stage, but when you look through the error log you see that SEED tries to deploy on DEV even though the command was to deploy on PROD:

tack Trace --------------------------------------------
 
ServerlessError: An error occurred: TreatmentLogs - dev-treatmentLogs already exists in stack arn:aws:cloudformation:us-east-1:968256005255:stack/spectrum-treatment-log-api-dev/df7e11d0-f373-11e8-8816-12c395c1242e.

Is there a way to configure SEED and the commands it runs on AutoDeploy?

Thanks and let me know if I should provide more info.


#2

This build has timed out and has queued all subsequent builds. I am wondering if I should just delete the app and start over…

Any insight on the seed side of things would be helpful. I have created a services directory that is holding this first service in the mono repo I’ve decided with… Ive defined them as needed in seed but there is an issue with promoting to prod as described above.


#3

I’m guessing you are getting some help with this?


#4

Yes there is. But on this end, I decided to try the following in my serverless.yml file:

provider:
  name: aws
  runtime: nodejs8.10
  stage: ${self:custom.stage}
  region: us-east-1
  # Environment variables made available through process.env
  environment: 
    tableName: ${self:custom.tableName}
    stripePrivateKey: ${self:custom.environment.stripePrivateKey}

However, when I set the stage as shown with ${self:custom.stage} I timeout on SEED.

When I set the stage to dev, I get an error from cloud formation saying that the dev service is already deployed.

I haven’t tried setting it to prod yet but then id imagine that if I set it to prod then it would never deploy to dev correct?

Im stuck here because it looks like this set of docs is out of date. Let me know if you have any advice. thanks!


#5

Any ideas on this one? Really having a hard time on this one. Set it up as mono-repo following docs on SEED but not having much luck… What should my stage be set as under the provider attribute in my serverless.yml? It looks like this field is guiding the deployment of resources in prod… thanks. @jayair


#6

@jayair

I just tried again and it failed to deploy to PROD. I am confused because the stage I have set in my provider starts with dev. So far so good, it deploys to prod an every thing is fine. Here is the data defined in my serverless.yml file:


# NOTE: Update this with your service name

# New service names create new projects in AWS once deployed

service: spectrum-treatment-log-api

# Use the serverless-webpack plugin to transpile ES6

plugins:

  - serverless-webpack

  - serverless-offline

# serverless-webpack configuration

# Enable auto-packing of external modules

custom:

  # Stages are based on what is passed in when running serverless

  # commands. Or fllback to settings in provider section.

  stage: ${opt:self, self:provider.stage}

  # Set the table name to use it for testing locally

  tableName: ${self:custom.stage}-treatmentLogs

  # Set DynamoDB throughput for prod and all other non-prod stages.

  tableThroughputs:

    prod: 5

    default: 1

  tableThroughput: ${self:custom.tableThroughputs.${self:custom.stage}, self:custom.tableThroughputs.default}

  # Load webpack config

  webpack:

    webpackConfig: ./webpack.config.js

    includeModules: true

  # Load secret environment variables based on the current stage

  # Fallback to default if it is not in PROD

  environment: ${file(env.yml):${self:custom.stage}, file(env.yml):default}

provider:

  name: aws

  runtime: nodejs8.10

  stage: dev

  region: us-east-1

  # Environment variables made available through process.env

  environment: 

    tableName: ${self:custom.tableName}

    stripePrivateKey: ${self:custom.environment.stripePrivateKey}

The problem is that when I try to promote it to prod I get an internal service error. It looks like even though you are explicitly calling the stage prod from the command line, SEED still wants to promote it as dev and then I get the AWS error that says the dev deployment already exists.

How can I get it to deploy to prod??? It is still trying to deploy to dev as you can see below. Here is the link and the error from the SEED build log this AM:

https://console.seed.run/lopezdp/spectrumstack/builds/12/services/treatmentlogs

⚡️ Init

====================

2018/12/03 11:45:58 Loading production build

====================

🛠 Compile

====================

$ npm install

npm WARN acorn-jsx@5.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/sane/node_modules/fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/chokidar/node_modules/fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 24081 packages in 8.769s

found 12 vulnerabilities (8 low, 4 high)

  run `npm audit fix` to fix them, or `npm audit` for details

====================

📦 Build

====================

2018/12/03 11:46:13 Applying secret environment variables

====================

🚀 Deploy

====================

2018/12/03 11:46:14 Deploying to: prod

$ SLS_DEBUG=* serverless deploy --stage prod --package promote-artifacts --force 

Serverless: Load command config

Serverless: Load command config:credentials

Serverless: Load command create

Serverless: Load command install

Serverless: Load command package

Serverless: Load command deploy

Serverless: Load command deploy:function

Serverless: Load command deploy:list

Serverless: Load command deploy:list:functions

Serverless: Load command invoke

Serverless: Load command invoke:local

Serverless: Load command info

Serverless: Load command logs

Serverless: Load command login

Serverless: Load command logout

Serverless: Load command metrics

Serverless: Load command print

Serverless: Load command remove

Serverless: Load command rollback

Serverless: Load command rollback:function

Serverless: Load command slstats

Serverless: Load command plugin

Serverless: Load command plugin

Serverless: Load command plugin:install

Serverless: Load command plugin

Serverless: Load command plugin:uninstall

Serverless: Load command plugin

Serverless: Load command plugin:list

Serverless: Load command plugin

Serverless: Load command plugin:search

Serverless: Load command config

Serverless: Load command config:credentials

Serverless: Load command rollback

Serverless: Load command rollback:function

Serverless: Load command webpack

Serverless: Load command offline

Serverless: Load command offline:start

 Serverless Warning --------------------------------------

  A valid file to satisfy the declaration 'file(env.yml):dev,file(env.yml):default' could not be found.

 Serverless Warning --------------------------------------

  A valid file to satisfy the declaration 'file(env.yml):dev,file(env.yml):default' could not be found.

Serverless: Invoke deploy

Serverless: Invoke aws:common:validate

Serverless: Invoke aws:common:moveArtifactsToTemp

Serverless: Invoke aws:deploy:deploy

Serverless: Uploading CloudFormation file to S3...

Serverless: Uploading artifacts...

Serverless: Uploading service .zip file to S3 (1.52 MB)...

Serverless: Validating template...

Serverless: Updating Stack...

Serverless: Checking Stack update progress...

............

Serverless: Operation failed!

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

  An error occurred: TreatmentLogs - dev-treatmentLogs already exists in stack arn:aws:cloudformation:us-east-1:968256005255:stack/spectrum-treatment-log-api-dev/df7e11d0-f373-11e8-8816-12c395c1242e.

  Stack Trace --------------------------------------------

ServerlessError: An error occurred: TreatmentLogs - dev-treatmentLogs already exists in stack arn:aws:cloudformation:us-east-1:968256005255:stack/spectrum-treatment-log-api-dev/df7e11d0-f373-11e8-8816-12c395c1242e.

    at provider.request.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:112:33)

From previous event:

    at AwsDeploy.monitorStack (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:26:12)

    at provider.request.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:95:30)

From previous event:

    at AwsDeploy.update (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:95:8)

From previous event:

    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:112:12)

From previous event:

    at AwsDeploy.updateStack (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:106:8)

From previous event:

    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:129:39)

From previous event:

    at Object.aws:deploy:deploy:updateStack [as hook] (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:125:10)

    at BbPromise.reduce (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:55)

From previous event:

    at PluginManager.invoke (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:22)

    at PluginManager.spawn (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:408:17)

    at AwsDeploy.BbPromise.bind.then (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:95:48)

From previous event:

    at Object.deploy:deploy [as hook] (/sls-1.29.2/node_modules/serverless/lib/plugins/aws/deploy/index.js:91:10)

    at BbPromise.reduce (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:55)

From previous event:

    at PluginManager.invoke (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:390:22)

    at PluginManager.run (/sls-1.29.2/node_modules/serverless/lib/classes/PluginManager.js:421:17)

    at variables.populateService.then.then (/sls-1.29.2/node_modules/serverless/lib/Serverless.js:157:33)

    at runCallback (timers.js:794:20)

    at tryOnImmediate (timers.js:752:5)

    at processImmediate [as _immediateCallback] (timers.js:729:5)

From previous event:

    at Serverless.run (/sls-1.29.2/node_modules/serverless/lib/Serverless.js:144:8)

    at serverless.init.then (/sls-1.29.2/node_modules/serverless/bin/serverless:43:50)

    at &lt;anonymous&gt;

  Get Support --------------------------------------------

     Docs:          docs.serverless.com

     Bugs:          github.com/serverless/serverless/issues

     Issues:        forum.serverless.com

  Your Environment Information -----------------------------

     OS:                     linux

     Node Version:           8.10.0

     Serverless Version:     1.29.2

2018/12/03 11:46:48 Error: exec: internal error

====================

🗑 Cleanup

====================

2018/12/03 11:46:48 Post deploy cleanup

#7

I’m guessing somebody helped you with this already.


#8

Yes thanks Frank helped to resolve this last week. I appreciate it.