I'm using SAM CLI v0.8.1. I'm trying to set environmental variable MY_TABLE_VAR as name of the table in my resources (MyTableResource). However, while running my app locally, the MY_TABLE_VAR is undefined. Can you tell me what's wrong in my template and how can I set it properly? Following is my SAM template:
Globals:
Function:
Timeout: 30
Runtime: nodejs8.10
Environment:
Variables:
MY_TABLE_VAR: !Ref MyTableResource
Resources:
MyTableResource:
Type: AWS::Serverless::SimpleTable
Properties:
TableName: table1
PrimaryKey:
Name: id
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Globals
CAN reference resources in theResources
section, but (probably) not all types. I managed to declare aAWS::Serverless::LayerVersion
resource object and set theLayers
property in theGlobals: Function
scope, despite the layer being created inside theResources
section. – Ory