AWS SAM Template - Defining Environment Variables for Lambda Function

  • Vish234
  • Topic Author
More
14 Aug 2023 02:47 #12413 by Vish234
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
Code:
template.yaml
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:
Code:
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!

Please Log in or Create an account to join the conversation.

  • pgilman
More
14 Aug 2023 10:11 #12416 by pgilman
Hi Vishal,

Wrong SAM! This is a forum for NREL's System Advisor Model (SAM).

For the AWS Serverless Application Model (SAM), see aws.amazon.com/serverless/sam/ .

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

Moderators: pgilman
Powered by Kunena Forum