- Posts: 2
AWS SAM Template - Defining Environment Variables for Lambda Function
- Vish234
- Topic Author
Less
More
14 Aug 2023 02:47 #12413
by Vish234
AWS SAM Template - Defining Environment Variables for Lambda Function was created 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
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:
Is this the correct approach, or am I missing something? Any help would be greatly appreciated. Thank you!
Code:
template.yaml
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
Less
More
- Posts: 5423
14 Aug 2023 10:11 #12416
by pgilman
Replied by pgilman on topic AWS SAM Template - Defining Environment Variables for Lambda Function
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.
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