aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Utilizing the "Globals" section of SAM is not respected

Open spockNinja opened this issue 8 years ago • 16 comments

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.

spockNinja avatar Dec 09 '17 23:12 spockNinja

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.

spockNinja avatar Dec 09 '17 23:12 spockNinja

Same issue for me, glad it is reported already.

metaskills avatar Jan 04 '18 23:01 metaskills

+1

stevehouel avatar Jan 11 '18 04:01 stevehouel

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
....

kpx-dev avatar Jan 16 '18 19:01 kpx-dev

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

cwonrails avatar Jan 23 '18 15:01 cwonrails

+1 to unsupported runtime issue

dimahavrylevych avatar Jan 24 '18 14:01 dimahavrylevych

+1 to unsupported runtime issue

lfdesousa avatar Jan 24 '18 14:01 lfdesousa

+1 to Globals and nodejs6.10

vasylk avatar Jan 30 '18 07:01 vasylk

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

nzoschke avatar Feb 21 '18 14:02 nzoschke

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

pacey avatar Feb 22 '18 09:02 pacey

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

tarasowski avatar Mar 07 '18 13:03 tarasowski

+1 to Globals

GuidoNebiolo avatar Mar 21 '18 10:03 GuidoNebiolo

+1 to Globals

ospikovets avatar Mar 22 '18 08:03 ospikovets

+1 to Globals

IainAdams avatar Apr 07 '18 22:04 IainAdams

+1 to Globals

vendablefall avatar Apr 28 '18 10:04 vendablefall

Globals are supported as of v0.3.0

Closing

jfuss avatar May 30 '18 13:05 jfuss