I'm working on an AWS Serverless Application Model (SAM) project and I'm trying to define environment variables for my Lambda function within the
file. I want to set specific configuration values that my Lambda function can access at runtime.I've looked through the AWS SAM documentation, but I'm having trouble finding a clear example of how to define environment variables directly in the template.Could someone provide guidance on the proper syntax and structure to define environment variables for a Lambda function using AWS SAM? Are there any best practices or considerations I should be aware of when setting up environment variables within the SAM template?Here's a snippet of what I have so far:
Resources:
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./my-lambda-code
Handler: index.handler
Runtime: nodejs14.x
Environment:
Variables:
MY_CONFIG_KEY: "my-config-value"
Is this the correct approach, or am I missing something? Any help would be greatly appreciated. Thank you!