serverless: schema validations for environment variables fail

For serverless 2.x, the schema validation fails for environment variables

With serverless.yaml that contains environment variables, e.g.

provider:
  environment:
    FLASK_ENV: development

functions:
  funcName:
    environment:
      ANY_ENV: avalue

The errors are like:

Serverless:   at 'functions.funcName.environment.ANY_ENV': unsupported configuration format
Serverless:   at 'provider.environment.FLASK_ENV': unsupported configuration format
serverless.yml
provider:
  environment:
    FLASK_ENV: development

functions:
  funcName:
    environment:
      ANY_ENV: avalue
sls package output
Serverless:   at 'functions.funcName.environment.ANY_ENV': unsupported configuration format
Serverless:   at 'provider.environment.FLASK_DEBUG': unsupported configuration format
Serverless:   at 'provider.environment.DATADOG_ENABLED': unsupported configuration format

Installed version

Framework Core: 2.2.0
Plugin: 4.0.4
SDK: 2.3.2
Components: 3.1.4

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I had the same issue after upgrading serverless from 1 to 2. What worked for me was to use a string value instead of integer. 1 👉 "1"

@tonivdv this issue was actually addressed, I just forgot to close it (closing it now)

Now answering your question, why you’re using Fn::Sub? In value you just use serverless variables, which are resolved independently. I believe your setup could be just:

custom:
  someUrl: https://${self:custom.someDomain}

@thtliife @stevenj handling of your case was just fixed with https://github.com/serverless/serverless/pull/8307 which was just published with v2.4.0 (after all I decided to not introduce any option, so it’ll work out of a box).