Aws-sam-cli: Utilizing the "Globals" section of SAM is not respected

Created on 10 Dec 2017  路  16Comments  路  Source: aws/aws-sam-cli

I am utilizing the Globals section of SAM. This is a great feature to help reduce copy-pasting in all of the Functions. However, sam-local does not appear to be respecting the runtime supplied in this section.

The Globals section of template.yml

Globals:
  Function:
    runtime: python3.6

And when I run sam local start-api, I receive errors like this for all of my endpoints:

2017/12/09 15:29:01 Ignoring FunctionName (functionPath) due to unsupported runtime ()
ERROR: None of the Serverless functions in your SAM template were able to be mounted. See above for errors.

I would be happy to make a pull request if this is a feature that would be welcomed, and if I could get some initial guidance on the internals of sam-local to know where this would fit best.

Based on a quick search of the source, I _think_ we would have to look for Globals and pass the runtime into https://github.com/awslabs/aws-sam-local/blob/develop/start.go#L78 when building the Functions.

Most helpful comment

+1 to Globals

All 16 comments

In the meantime, the simple workaround is to copy the runtime setting into each of your functions. I just have that change stashed in git for now and don't commit it.

Same issue for me, glad it is reported already.

+1

I'm having similar as well:

$ sam local invoke MyLambda -e ./test/fixtures/test.json
2018/01/16 11:25:08 Successfully parsed template.yml
ERROR: json: cannot unmarshal number into Go value of type string
2018/01/16 11:25:08 Connected to Docker 1.35
2018/01/16 11:25:08 Could not initiate  runtime: unsupported runtime
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Putting the Runtime: nodejs6.10 back into the lambda function definition works fine.

$ sam local invoke MyLambda -e ./test/fixtures/test.json
2018/01/16 11:29:29 Successfully parsed template.yml
ERROR: json: cannot unmarshal number into Go value of type string
2018/01/16 11:29:29 Connected to Docker 1.35
2018/01/16 11:29:29 Fetching lambci/lambda:nodejs6.10 image for nodejs6.10 runtime...
nodejs6.10: Pulling from lambci/lambda
....

Exact same issue @kienpham2000 posted re: Runtime: nodejs6.10 in the Globals section.

+1 to unsupported runtime issue

+1 to unsupported runtime issue

+1 to Globals and nodejs6.10

I also needed to copy the Handler property back from Globals to each function

Look forward to this being resolved. I'm not a go developer but would be happy to help where I can.

+1 to Globals and nodejs6.10 || would be great to get nodejs 8...

+1 to Globals

+1 to Globals

+1 to Globals

+1 to Globals

Globals are supported as of v0.3.0

Closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asyba picture asyba  路  3Comments

cmccoypdx picture cmccoypdx  路  3Comments

terlar picture terlar  路  3Comments

cvuijst picture cvuijst  路  3Comments

Caian picture Caian  路  3Comments