Environment variables not updating in new lambda function version
See original GitHub issueThis is a Bug Report
Description
For bug reports:
-
What went wrong? New environment variables are not deploying to new function version for AWS Lambda. I’ve verified that the new variables are properly set inside the CloudFormation stack template. I’ve also ran every variation of deploy (with
-p
, with-f
, with--force
, with--update-config
, and with code changes). My base use case is tosls package
first, then deploy with-p
-
What did you expect should have happened? Changing or adding environment variables in serverless.yml should update environment variables in lambda console for the corresponding function version when deployed.
-
What was the config you used?
service:
name: foo-service
awsKmsKeyArn: ${ssm:/infra/lambda-env-kms-key-id}
frameworkVersion: "^1.25.0"
functions:
foo-service:
name: ${self:custom.stageNames.${self:provider.stage}, self:custom.defaultName}
handler: dist/lambda.handler
provider:
name: aws
stage: ${opt:stage, self:custom.defaultStage}
region: us-east-1
profile: serverless
deploymentBucket:
name: ${ssm:/infra/serverless-deployment-bucket}
serverSideEncryption: aws:kms
sseKMSKeyId: ${ssm:/infra/serverless-deployment-bucket-kms-key-id}
# service function settings
runtime: nodejs6.10
memorySize: 1024
timeout: 30
environment:
SERVERLESS_STAGE: ${self:provider.stage}
SERVERLESS_ALIAS: ${self:provider.alias}
NODE_ENV: ${ssm:/infra/NODE_ENV}
MY_NEW_ENV_VAR: ${ssm:/infra/foobar}
vpc:
subnetIds:
- ${ssm:/infra/lambda-subnet}
securityGroupIds:
- ${ssm:/infra/lambda-sg}
custom:
defaultName: ${self:service}__${self:provider.stage}
defaultStage: staging
defaultRegion: us-east-1
stageNames:
staging: ${self:service}
prod: ${self:service}
package:
include:
- dist/**
- node_modules/**
- '!**/*.d.ts'
- '!**/*.test.js'
- '!**/*.spec.js'
- '!**/__tests__/**'
exclude:
- '**'
plugins:
- serverless-pseudo-parameters
- serverless-aws-alias
- What stacktrace or error message from your provider did you see? No error message. Package and Deploy were successful.
Similar or dependent issues:
Additional Data
- Serverless Framework Version you’re using: 1.25.0
- Operating System: Mac High Sierra locally and Ubuntu in CircleCI
- Stack Trace: None
- Provider Error messages: None
Issue Analytics
- State:
- Created 6 years ago
- Reactions:24
- Comments:54 (14 by maintainers)
Top Results From Across the Web
Configure Lambda environment variables - AWS
To change the environment variables of a published Lambda function version, you must first change the current, unpublished function version ($ ...
Read more >AWS Lambda environment variable is not updated when ...
I want to update AWS Lambda environment variable. The function is defined in SAM. Environment variable refers Parameter. Like this.
Read more >How do I Update Lambda Environment Variables using...
Edit to add: i updated the pipe version to 1.6.0 and updated path to config file to './stagingconfig.json' and it worked fine.
Read more >AWS Lambda Environment Variables Best Practices
... official AWS Lambda documentation, environment variables are a tool that allows you to adjust your function's behavior without updating ...
Read more >AWS Lambda Functions - Serverless Framework
Serverless will create an ECR repository for your image, but it currently does not manage updates to it. An ECR repository is created...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any update on this?
It appears that the impact of this issue is not limited only to environment variables, but other lambda configuration options like timeout and VPC.
Confirmed with 1.26.0, Mac OS High Sierra locally.