question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment variables not updating in new lambda function version

See original GitHub issue

This 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 to sls 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:closed
  • Created 6 years ago
  • Reactions:24
  • Comments:54 (14 by maintainers)

github_iconTop GitHub Comments

20reactions
chrisyorkstoncommented, Sep 24, 2018

Any update on this?

5reactions
nullfluxcommented, Feb 16, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found