When running sams locally to test my api gateway and passing environment variables, I can run the command
sam local start-api -n env-vars.json
This works well when the environment variables are tied to a specific function like this
MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs8.10
CodeUri: .
Environment:
Variables:
FIRST_BUCKET: !Ref firstBucket
SECOND_BUCKET: !Ref secondBucket
However, I currently have global enviroment variables like this
Globals:
Function:
CodeUri: .
Runtime: nodejs8.10
Environment:
Variables:
FIRST_BUCKET: !Ref firstBucket
SECOND_BUCKET: !Ref secondBucket
How can I pass custom global environment variables to SAMS using env-var.json
?
I'd expect to be able to do something like this for my env-var.json
file
{
"Globals": {
"Function": {
"FIRST_BUCKET": "this-is-my-bucket-name"
}
}
}
Unfortunately, this does not work and I can not find any resources online showing the correct syntax to achieve this behavior.