Skip to content

Default values don't work in variables within ${file} #5807

Closed

Description

@bratchenko

This is a Bug Report

Description

After updating to serverless 1.37 our serverless.yml (almost) silently stopped setting environment to lambdas. The issue ended up being related to default values of variables when including external files.

Here is an example config:

service: my-service

custom:
  config: ${file(config/${opt:stage, 'development'}.yml)}

provider:
  name: aws
  stage: ${self:custom.stage}
  environment: ${self:custom.config.environment}

The output of sls print -s production is:

service: my-service
custom:
  config:
    environment:
      IS_PRODUCTION: 'True'
provider:
  stage: production
  name: aws

Additionally, serverless shows a warning: A valid service attribute to satisfy the declaration 'self:custom.config.environment' could not be found.

If I remove the default value for opt:stage and use the following config, the problem disappears:

sls print -s production

service: my-service
custom:
  config:
    environment:
      IS_PRODUCTION: 'True'
provider:
  stage: production
  name: aws
  environment: <<< ENVIRONMENT IS PRESENT NOW
     $ref: '$["custom"]["config"]["environment"]'

The same config (with the default value) works just fine with [email protected].

Activity

  1. pmuens commented on Feb 8, 2019

    @pmuens
    Contributor

    Sorry for regressing here!

    Fortunately @jerizm jumped in and fixed it. Just tested and merged it a couple of seconds ago...

  2. bratchenko commented on Feb 8, 2019

    @bratchenko
    ContributorAuthor

    Thanks for the quick resolution!

  3. pmuens commented on Feb 8, 2019

    @pmuens
    Contributor

    Hey everyone 👋

    We just published a patch release (v1.37.1 which includes this fix). Should be available soon... Just update the Serverless Framework and you should be good.

    Thanks for the quick resolution!

    Sure thing 👍

    Shoutouts to @jerizm who fixed this 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions