New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly create stage variables JSON generated incorrectly #499

Closed
ecwillis opened this Issue Jan 20, 2016 · 14 comments

Comments

Projects
None yet
9 participants
@ecwillis

ecwillis commented Jan 20, 2016

After creating a new stage, I ran into an error attempting to deploy a function to that stage.

The error read Missing required key 'Role' in params.

Upon reviewing the configurations I found that the s-variables...json files differed and the one that I was attempting to deploy against was in face missing a role.

Here was the contents of the default development role variables:

{
   "region": "us-east-1",
   "resourcesStackName": "l[stack-name]",
   "iamRoleArnLambda": "[role-string]"
 }

And here was the contents of the new stage that I created:

{
   "region": "us-east-1"
}

Additionally it appears that there was no new role created in my AWS account (although I am not sure that is supposed to happen).

This also may duplicate #467 though I am unsure of the scope of that issue.

@ac360

This comment has been minimized.

Show comment
Hide comment
@ac360

ac360 Jan 20, 2016

Member

@ecwillis Thanks. On it right now 👍

Member

ac360 commented Jan 20, 2016

@ecwillis Thanks. On it right now 👍

@ac360

This comment has been minimized.

Show comment
Hide comment
@ac360

ac360 Jan 20, 2016

Member

@ecwillis I can't seem to recreate? Which version of Serverless are you using and could you giv eme any further details?

Member

ac360 commented Jan 20, 2016

@ecwillis I can't seem to recreate? Which version of Serverless are you using and could you giv eme any further details?

@ecwillis

This comment has been minimized.

Show comment
Hide comment
@ecwillis

ecwillis Jan 20, 2016

@ac360 I am using the latest version. We are setting up a project with two developers so I was attempting to set up serverless with three stages from scratch... So my workflow was something like this:

serverless project create
serverless component create
serverless stage create

So originally I didn't deploy anything prior to creating the new stage. At this point, I tried to deploy to the new stage and I got the error above.

Oddly enough, I then deployed the function and endpoint to the development stage (default), and then I was able to deploy the function to the new stage, but only after an initial deploy.

However, I was still not able to deploy an endpoint to the stage. I do have information about that.

From the debug output:

ubuntu@ip-172-31-7-76:~/Projects/serverlessproject/main/api/track$ serverless endpoint deploy -s ericdev -r us-east-1 --debug
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ProjectCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectCreate plugin loaded +7ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ProjectInstall.js +3ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectInstall plugin loaded +44ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ComponentCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ComponentCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ModuleCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ModuleCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionRun.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRun plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionCreate plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionRunLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRunLambdaNodeJs plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionDeploy.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionDeploy plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodePackageLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodePackageLambdaNodejs plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodeDeployLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeDeployLambdaNodejs plugin loaded +37ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodeEventDeployLambda.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeEventDeployLambda plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeploy plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointBuildApiGateway plugin loaded +6ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/DashDeploy.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.DashDeploy plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointDeployApiGateway.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeployApiGateway plugin loaded +7ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/StageCreate.js +2ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.StageCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/RegionCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.RegionCreate plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvList.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvList plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvGet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvGet plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvSet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvSet plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvUnset.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvUnset plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ResourcesDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ResourcesDeploy plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless CLI raw input:  +1ms { _: [ 'endpoint', 'deploy' ],
  s: 'ericdev',
  r: 'us-east-1',
  debug: true }
  serverless:lib.node_modules.serverless.lib.Serverless CLI processed input:  +4ms { context: 'endpoint',
  action: 'deploy',
  options: 
   { stage: 'ericdev',
     region: 'us-east-1',
     aliasEndpoint: null,
     aliasRestApi: null,
     description: null,
     all: null },
  params: { paths: [] },
  raw: 
   { _: [ 'endpoint', 'deploy' ],
     s: 'ericdev',
     r: 'us-east-1',
     debug: true } }

Serverless: Deploying endpoints in "ericdev" to the following regions: us-east-1  
Serverless: /   serverless:lib.node_modules.serverless.lib.utils.aws.ApiGateway "ericdev - us-east-1": found existing REST API on AWS API Gateway with name: serverlessproject +442ms
Serverless: Failed to deploy endpoints in "ericdev" to the following regions:  
Serverless: us-east-1 ------------------------  
Serverless:   GET - api/track: Cannot read property 'replace' of undefined  
  serverless:lib.node_modules.serverless.lib.actions.EndpointDeploy TypeError: Cannot read property 'replace' of undefined
    at Builder._validateAndPrepare (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:131:139)
    at Builder.build (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:77:20)
    at EndpointBuildApiGateway.endpointBuildApiGateway (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:57:22)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at /usr/lib/node_modules/serverless/lib/Serverless.js:176:25
    at Array.reduce (native)
    at Serverless._execute (/usr/lib/node_modules/serverless/lib/Serverless.js:175:26)
    at Object.actions.(anonymous function) [as endpointBuildApiGateway] (/usr/lib/node_modules/serverless/lib/Serverless.js:377:20)
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:299:42
From previous event:
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:283:35
    at iterate (/usr/lib/node_modules/serverless/node_modules/async/lib/async.js:146:13)
    at Object.async.eachSeries (/usr/lib/node_modules/serverless/node_modules/async/lib/async.js:162:9)
    at BbPromise.then.newEvt.options.stage (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:279:19)
From previous event:
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:276:18
From previous event:
    at EndpointDeploy._deployEndpointsByRegion (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:268:10)
    at EndpointDeploy.<anonymous> (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:228:24)
From previous event:
    at EndpointDeploy._processDeployment (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:225:10)
From previous event:
    at EndpointDeploy.endpointDeploy (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:112:10)
From previous event:
    at /usr/lib/node_modules/serverless/lib/Serverless.js:151:29
    at Array.reduce (native)
    at /usr/lib/node_modules/serverless/lib/Serverless.js:150:30
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Serverless._execute (/usr/lib/node_modules/serverless/lib/Serverless.js:148:10)
    at Serverless.actions.(anonymous function) (/usr/lib/node_modules/serverless/lib/Serverless.js:377:20)
    at Serverless.command (/usr/lib/node_modules/serverless/lib/Serverless.js:346:38)
    at Object.<anonymous> (/usr/lib/node_modules/serverless/bin/serverless:16:12)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3 +11ms
Serverless:   
Serverless: Run this again with --debug to get more error information... 

ecwillis commented Jan 20, 2016

@ac360 I am using the latest version. We are setting up a project with two developers so I was attempting to set up serverless with three stages from scratch... So my workflow was something like this:

serverless project create
serverless component create
serverless stage create

So originally I didn't deploy anything prior to creating the new stage. At this point, I tried to deploy to the new stage and I got the error above.

Oddly enough, I then deployed the function and endpoint to the development stage (default), and then I was able to deploy the function to the new stage, but only after an initial deploy.

However, I was still not able to deploy an endpoint to the stage. I do have information about that.

From the debug output:

ubuntu@ip-172-31-7-76:~/Projects/serverlessproject/main/api/track$ serverless endpoint deploy -s ericdev -r us-east-1 --debug
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ProjectCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectCreate plugin loaded +7ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ProjectInstall.js +3ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectInstall plugin loaded +44ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ComponentCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ComponentCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ModuleCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ModuleCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionRun.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRun plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionCreate plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionRunLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRunLambdaNodeJs plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/FunctionDeploy.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionDeploy plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodePackageLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodePackageLambdaNodejs plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodeDeployLambdaNodeJs.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeDeployLambdaNodejs plugin loaded +37ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/CodeEventDeployLambda.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeEventDeployLambda plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeploy plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointBuildApiGateway plugin loaded +6ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/DashDeploy.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.DashDeploy plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EndpointDeployApiGateway.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeployApiGateway plugin loaded +7ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/StageCreate.js +2ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.StageCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/RegionCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.RegionCreate plugin loaded +5ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvList.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvList plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvGet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvGet plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvSet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvSet plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/EnvUnset.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvUnset plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/lib/node_modules/serverless/lib/actions/ResourcesDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ResourcesDeploy plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless CLI raw input:  +1ms { _: [ 'endpoint', 'deploy' ],
  s: 'ericdev',
  r: 'us-east-1',
  debug: true }
  serverless:lib.node_modules.serverless.lib.Serverless CLI processed input:  +4ms { context: 'endpoint',
  action: 'deploy',
  options: 
   { stage: 'ericdev',
     region: 'us-east-1',
     aliasEndpoint: null,
     aliasRestApi: null,
     description: null,
     all: null },
  params: { paths: [] },
  raw: 
   { _: [ 'endpoint', 'deploy' ],
     s: 'ericdev',
     r: 'us-east-1',
     debug: true } }

Serverless: Deploying endpoints in "ericdev" to the following regions: us-east-1  
Serverless: /   serverless:lib.node_modules.serverless.lib.utils.aws.ApiGateway "ericdev - us-east-1": found existing REST API on AWS API Gateway with name: serverlessproject +442ms
Serverless: Failed to deploy endpoints in "ericdev" to the following regions:  
Serverless: us-east-1 ------------------------  
Serverless:   GET - api/track: Cannot read property 'replace' of undefined  
  serverless:lib.node_modules.serverless.lib.actions.EndpointDeploy TypeError: Cannot read property 'replace' of undefined
    at Builder._validateAndPrepare (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:131:139)
    at Builder.build (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:77:20)
    at EndpointBuildApiGateway.endpointBuildApiGateway (/usr/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:57:22)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at /usr/lib/node_modules/serverless/lib/Serverless.js:176:25
    at Array.reduce (native)
    at Serverless._execute (/usr/lib/node_modules/serverless/lib/Serverless.js:175:26)
    at Object.actions.(anonymous function) [as endpointBuildApiGateway] (/usr/lib/node_modules/serverless/lib/Serverless.js:377:20)
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:299:42
From previous event:
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:283:35
    at iterate (/usr/lib/node_modules/serverless/node_modules/async/lib/async.js:146:13)
    at Object.async.eachSeries (/usr/lib/node_modules/serverless/node_modules/async/lib/async.js:162:9)
    at BbPromise.then.newEvt.options.stage (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:279:19)
From previous event:
    at /usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:276:18
From previous event:
    at EndpointDeploy._deployEndpointsByRegion (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:268:10)
    at EndpointDeploy.<anonymous> (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:228:24)
From previous event:
    at EndpointDeploy._processDeployment (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:225:10)
From previous event:
    at EndpointDeploy.endpointDeploy (/usr/lib/node_modules/serverless/lib/actions/EndpointDeploy.js:112:10)
From previous event:
    at /usr/lib/node_modules/serverless/lib/Serverless.js:151:29
    at Array.reduce (native)
    at /usr/lib/node_modules/serverless/lib/Serverless.js:150:30
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Serverless._execute (/usr/lib/node_modules/serverless/lib/Serverless.js:148:10)
    at Serverless.actions.(anonymous function) (/usr/lib/node_modules/serverless/lib/Serverless.js:377:20)
    at Serverless.command (/usr/lib/node_modules/serverless/lib/Serverless.js:346:38)
    at Object.<anonymous> (/usr/lib/node_modules/serverless/bin/serverless:16:12)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3 +11ms
Serverless:   
Serverless: Run this again with --debug to get more error information... 
@ac360

This comment has been minimized.

Show comment
Hide comment
@ac360

ac360 Jan 20, 2016

Member

Thanks @ecwillis I will look into this in a few hours 👍 Just a bit behind today

Member

ac360 commented Jan 20, 2016

Thanks @ecwillis I will look into this in a few hours 👍 Just a bit behind today

@ac360 ac360 added bug labels Jan 20, 2016

@eahefnawy

This comment has been minimized.

Show comment
Hide comment
@eahefnawy

eahefnawy Jan 21, 2016

Member

@ecwillis Thanks for reporting. This is not really a bug, but a feature :) ... The reason you're missing the resourcesStackName and iamRoleArnLambda variables right after you create a stage/region is that we no longer deploy resources automatically on stage/regionCreate ... We used to do that previously, but we thought it slows down the process, and you can always deploy your resources when you want to with sls resources deploy. However we do deploy resources automatically to the default development stage when you initially create a new project. That's why deploying to the development stage works for you.

So all you have to do is just run sls resources deploy after your run sls stage create or sls region create, and you'll find those variables in the relevant JSON files.

I hope this clears it up. We're sorry we didn't clarify this earlier (I'm gonna emphasize it on the docs now), and please let us know your feedback about this new workflow.

Cheers!

Member

eahefnawy commented Jan 21, 2016

@ecwillis Thanks for reporting. This is not really a bug, but a feature :) ... The reason you're missing the resourcesStackName and iamRoleArnLambda variables right after you create a stage/region is that we no longer deploy resources automatically on stage/regionCreate ... We used to do that previously, but we thought it slows down the process, and you can always deploy your resources when you want to with sls resources deploy. However we do deploy resources automatically to the default development stage when you initially create a new project. That's why deploying to the development stage works for you.

So all you have to do is just run sls resources deploy after your run sls stage create or sls region create, and you'll find those variables in the relevant JSON files.

I hope this clears it up. We're sorry we didn't clarify this earlier (I'm gonna emphasize it on the docs now), and please let us know your feedback about this new workflow.

Cheers!

@ac360

This comment has been minimized.

Show comment
Hide comment
@ac360

ac360 Jan 21, 2016

Member

Perhaps this was the wrong move and we should bring it back. I'm going to put this on the Road Map to bring back.

Member

ac360 commented Jan 21, 2016

Perhaps this was the wrong move and we should bring it back. I'm going to put this on the Road Map to bring back.

@ac360 ac360 closed this Jan 21, 2016

@cdichiara

This comment has been minimized.

Show comment
Hide comment
@cdichiara

cdichiara Mar 7, 2016

Hi ... ran into the same problem myself. Tried your solution, sls resources deploy, but I'm attempting to set up the developers without using an administrative-level secret key configured. So I ran sls resources deploy -c, uploaded the s-resources-cf-{stage}.json file to CloudFormation with the administrative account ... but now I realize from your response here that there is some configuration information placed back into the s-variables-{stage}-{region}.json file that are missing because of my manual step? Because here are the contents of my s-variables-carmine-us-east-1.json file:

{
   "region": "us-east-1",
   "apiGatewayApi": "iRewardHealth-lambda"
}

Here's the output of my deployment.
Deploy Error.txt

I posted here just in case someone else ran into this problem with the approach I'm trying.

I suppose my real question is: is there a good guide to the manual steps you have to take if you're not using an administrative-level key, or am I just setting myself up for failure attempting this approach? I'm going to keep on looking around through the documentation, but any little tips would be lovely.

Thanks,

Carmine

cdichiara commented Mar 7, 2016

Hi ... ran into the same problem myself. Tried your solution, sls resources deploy, but I'm attempting to set up the developers without using an administrative-level secret key configured. So I ran sls resources deploy -c, uploaded the s-resources-cf-{stage}.json file to CloudFormation with the administrative account ... but now I realize from your response here that there is some configuration information placed back into the s-variables-{stage}-{region}.json file that are missing because of my manual step? Because here are the contents of my s-variables-carmine-us-east-1.json file:

{
   "region": "us-east-1",
   "apiGatewayApi": "iRewardHealth-lambda"
}

Here's the output of my deployment.
Deploy Error.txt

I posted here just in case someone else ran into this problem with the approach I'm trying.

I suppose my real question is: is there a good guide to the manual steps you have to take if you're not using an administrative-level key, or am I just setting myself up for failure attempting this approach? I'm going to keep on looking around through the documentation, but any little tips would be lovely.

Thanks,

Carmine

@alastaircoote

This comment has been minimized.

Show comment
Hide comment
@alastaircoote

alastaircoote Apr 19, 2016

Just to bump the previous comment - I ran into the same issue with not knowing where to place the output from the CloudFormation UI. In the end I just gave the AWS role AdministratorAccess for the stage create command then removed it afterwards.

alastaircoote commented Apr 19, 2016

Just to bump the previous comment - I ran into the same issue with not knowing where to place the output from the CloudFormation UI. In the end I just gave the AWS role AdministratorAccess for the stage create command then removed it afterwards.

@BerndWessels

This comment has been minimized.

Show comment
Hide comment
@BerndWessels

BerndWessels Apr 27, 2016

@cdichiara @alastaircoote The problem is that on the first successful deployment of a resource the output parameters defined in s-resources-cf.json get populated and stored in the _meta folder.

But since you are setting up new machines without the _meta folder you are missing these output variables for the existing resources.

I guess at the moment the only way to work around that issue is to share the _meta folder with your colleagues. There is a serverless plugin for that.

And I hope that the serverless team will find a way to populate the output variables for already deployed resources in future versions.

BerndWessels commented Apr 27, 2016

@cdichiara @alastaircoote The problem is that on the first successful deployment of a resource the output parameters defined in s-resources-cf.json get populated and stored in the _meta folder.

But since you are setting up new machines without the _meta folder you are missing these output variables for the existing resources.

I guess at the moment the only way to work around that issue is to share the _meta folder with your colleagues. There is a serverless plugin for that.

And I hope that the serverless team will find a way to populate the output variables for already deployed resources in future versions.

@cdichiara

This comment has been minimized.

Show comment
Hide comment
@cdichiara

cdichiara Apr 27, 2016

Ah ... yes, definitely, I agree with you, there is the complexity of how to create _meta folders on a new build.

Actually, I think @alastaircoote & my struggles are that the serverless documentation does a good job in guiding us not to be leaving superuser-level access keys around our serverless projects, but instead to use poweruser-level access keys. Both Alastair & I ran into the difficulty that, when we went to manually install resources by logging into the AWS Console, we ran into related issues around where to put the output. I realize now that, with some more experience with CloudFormation, I can find the outputs and put them in the correct file. I think @alastaircoote 's solution is the most effective - grant superuser access while generating the resources, and then revoke it. It feels like more a documentation solution to me, in the end...

Looking back now, I feel that the bigger struggle with resources is that there are times in development that I want to change resources of a stage, and then the whole CloudFormation process really becomes a drag. Because I can't just add a new policy and then rerun sls resources deploy, like I might re-run sls endpoint deploy, because CloudFormation will fail on all the pre-existing resources. This happens regardless of whether I do it manually or not ... but this is really another issue than what we ran into here.

cdichiara commented Apr 27, 2016

Ah ... yes, definitely, I agree with you, there is the complexity of how to create _meta folders on a new build.

Actually, I think @alastaircoote & my struggles are that the serverless documentation does a good job in guiding us not to be leaving superuser-level access keys around our serverless projects, but instead to use poweruser-level access keys. Both Alastair & I ran into the difficulty that, when we went to manually install resources by logging into the AWS Console, we ran into related issues around where to put the output. I realize now that, with some more experience with CloudFormation, I can find the outputs and put them in the correct file. I think @alastaircoote 's solution is the most effective - grant superuser access while generating the resources, and then revoke it. It feels like more a documentation solution to me, in the end...

Looking back now, I feel that the bigger struggle with resources is that there are times in development that I want to change resources of a stage, and then the whole CloudFormation process really becomes a drag. Because I can't just add a new policy and then rerun sls resources deploy, like I might re-run sls endpoint deploy, because CloudFormation will fail on all the pre-existing resources. This happens regardless of whether I do it manually or not ... but this is really another issue than what we ran into here.

@BerndWessels

This comment has been minimized.

Show comment
Hide comment
@BerndWessels

BerndWessels Apr 28, 2016

@cdichiara right, I also have that gut feeling that resource deployment via cloud formation might still not be quite production ready yet because it doesn't cover a lot of (not even) edge cases.
But lets hope it will improve over time.

BerndWessels commented Apr 28, 2016

@cdichiara right, I also have that gut feeling that resource deployment via cloud formation might still not be quite production ready yet because it doesn't cover a lot of (not even) edge cases.
But lets hope it will improve over time.

@csterwa

This comment has been minimized.

Show comment
Hide comment
@csterwa

csterwa Jul 2, 2016

Has this been fixed? I am getting this error in a Continuous Integration server environment where the Docker container that is running the build each time has to re-initialize the project. I'm also deploying the resources again. The functions are deployed just fine but endpoints won't deploy in that environment. It is interesting since deployment of endpoints is working from my laptop which is original place that I deployed from.

csterwa commented Jul 2, 2016

Has this been fixed? I am getting this error in a Continuous Integration server environment where the Docker container that is running the build each time has to re-initialize the project. I'm also deploying the resources again. The functions are deployed just fine but endpoints won't deploy in that environment. It is interesting since deployment of endpoints is working from my laptop which is original place that I deployed from.

@BernhardLenz

This comment has been minimized.

Show comment
Hide comment
@BernhardLenz

BernhardLenz Jul 19, 2016

@ecwillis @eahefnawy @ac360 Thanks all for the detailed information about this problem! What I am trying to do is to NOT use couldfront to create new roles but instead re-use existing roles for my lambda (e.g. the commonly used lambda-s3-execution-role). For that I changed the custom-role in s-function.json to customRole": "arn:aws:iam::xxxxxxxxxxx:role/lambda-s3-execution-role. However with that I also ran into the Serverless: GET - list: Cannot read property 'replace' of undefined" error on line ProviderAws.js:525:11. Thanks to Eric's post I figured to add "iamRoleArnLambda": "arn:aws:iam::524022332698:role/lambda-s3-execution-role" to s-variables-dev-useast1.json file which solved the problem.

Are there any recommendations or tips on re-using roles, rather than creating new ones for each serverless lambda?

BernhardLenz commented Jul 19, 2016

@ecwillis @eahefnawy @ac360 Thanks all for the detailed information about this problem! What I am trying to do is to NOT use couldfront to create new roles but instead re-use existing roles for my lambda (e.g. the commonly used lambda-s3-execution-role). For that I changed the custom-role in s-function.json to customRole": "arn:aws:iam::xxxxxxxxxxx:role/lambda-s3-execution-role. However with that I also ran into the Serverless: GET - list: Cannot read property 'replace' of undefined" error on line ProviderAws.js:525:11. Thanks to Eric's post I figured to add "iamRoleArnLambda": "arn:aws:iam::524022332698:role/lambda-s3-execution-role" to s-variables-dev-useast1.json file which solved the problem.

Are there any recommendations or tips on re-using roles, rather than creating new ones for each serverless lambda?

@thoean

This comment has been minimized.

Show comment
Hide comment
@thoean

thoean Sep 5, 2016

We use gulp to deploy a serverless project, and we do some pre-work before calling serverless deploy. To address the above problem, we call the following functions (and more functionality to figure out whether we need to call serverless project init or serverless stage create or simply nothing).:

function readDetails() {

    return new Promise((resolve, reject) => {
        let region = config.get('service.region');
        let stage = config.get('service.stage');
        let variableFile = '_meta/variables/s-variables-' + stage + '-' + region.split('-').join('') + '.json';
        fs.readFile(variableFile, 'utf8', (err, data) => {
            if (err) {
                reject(err);
            }
            else {
                let jsonContent = JSON.parse(data);
                if ((jsonContent.resourcesStackName || jsonContent.iamRoleArnLambda) === undefined) {
                    resolve({ variables: data, variableFile: variableFile });
                }
                else {
                    resolve();
                }
            }
        });
    });
};


function updateVariables(vars) {

    // only relevant if arguments are passed
    if (arguments.length === 0 || !vars.variables || !vars.variableFile) {
        return Promise.resolve();
    }

    // get cloud formation stack
    console.log('Get Cloud Formation Variables...');
    let region = config.get('service.region');
    let project = config.get('service.project');
    let stage = config.get('service.stage');
    let stackName = [project, stage, 'r'].join('-');
    let cloudformation = new AWS.CloudFormation({ region: region });
    return new Promise((resolve, reject) => {
        let p = cloudformation.describeStacks({ StackName: stackName }).promise();
        p.then((data) => {
            let outputKey = data.Stacks[0].Outputs[0].OutputKey;
            let outputValue = data.Stacks[0].Outputs[0].OutputValue;
            if (outputKey === 'IamRoleArnLambda') {
                // update variable file
                let jsonContent = JSON.parse(vars.variables);
                jsonContent.resourcesStackName = stackName;
                jsonContent.iamRoleArnLambda = outputValue;
                let newVariables = JSON.stringify(jsonContent, null, 2);
                fs.writeFile(vars.variableFile, newVariables, (err) => {
                    if (err) {
                        reject(err);
                    } else {
                        resolve();
                    }
                });
            } else {
                reject('IamRoleArnLambda was not a key of the cloud formation stack.');
            }
        });
        p.catch(reject);
    });
};

I haven't tried serverless 1.x yet, which I hope has addressed some of the workarounds that are applied here.

thoean commented Sep 5, 2016

We use gulp to deploy a serverless project, and we do some pre-work before calling serverless deploy. To address the above problem, we call the following functions (and more functionality to figure out whether we need to call serverless project init or serverless stage create or simply nothing).:

function readDetails() {

    return new Promise((resolve, reject) => {
        let region = config.get('service.region');
        let stage = config.get('service.stage');
        let variableFile = '_meta/variables/s-variables-' + stage + '-' + region.split('-').join('') + '.json';
        fs.readFile(variableFile, 'utf8', (err, data) => {
            if (err) {
                reject(err);
            }
            else {
                let jsonContent = JSON.parse(data);
                if ((jsonContent.resourcesStackName || jsonContent.iamRoleArnLambda) === undefined) {
                    resolve({ variables: data, variableFile: variableFile });
                }
                else {
                    resolve();
                }
            }
        });
    });
};


function updateVariables(vars) {

    // only relevant if arguments are passed
    if (arguments.length === 0 || !vars.variables || !vars.variableFile) {
        return Promise.resolve();
    }

    // get cloud formation stack
    console.log('Get Cloud Formation Variables...');
    let region = config.get('service.region');
    let project = config.get('service.project');
    let stage = config.get('service.stage');
    let stackName = [project, stage, 'r'].join('-');
    let cloudformation = new AWS.CloudFormation({ region: region });
    return new Promise((resolve, reject) => {
        let p = cloudformation.describeStacks({ StackName: stackName }).promise();
        p.then((data) => {
            let outputKey = data.Stacks[0].Outputs[0].OutputKey;
            let outputValue = data.Stacks[0].Outputs[0].OutputValue;
            if (outputKey === 'IamRoleArnLambda') {
                // update variable file
                let jsonContent = JSON.parse(vars.variables);
                jsonContent.resourcesStackName = stackName;
                jsonContent.iamRoleArnLambda = outputValue;
                let newVariables = JSON.stringify(jsonContent, null, 2);
                fs.writeFile(vars.variableFile, newVariables, (err) => {
                    if (err) {
                        reject(err);
                    } else {
                        resolve();
                    }
                });
            } else {
                reject('IamRoleArnLambda was not a key of the cloud formation stack.');
            }
        });
        p.catch(reject);
    });
};

I haven't tried serverless 1.x yet, which I hope has addressed some of the workarounds that are applied here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment