serverless / serverless/serverless

In serverless@3 serverless.yml aws requests halt execution, even when a defaultValue is specified

Open
#11,263 15 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug cat/variable needs feedback
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

Are you certain it's a bug?
  • Yes, it looks like a bug
Is the issue caused by a plugin?
  • It is not a plugin issue
Are you using the latest v3 release?
  • Yes, I'm using the latest v3 release
Is there an existing issue for this?
  • I have searched existing issues, it hasn't been reported yet
Issue description

When upgrading a project from serverless@2 to serverless@3, I'm noticing that there is a breaking change where any AWS related errors in serverless.yml immediately halt execution, even if a defaultValue is specified.

For example, in serverless@2 this worked fine:

SOME_KEY: ${ssm:/somepath/somekey~false, env:SOME_KEY}

Explanation: If we tried to fetch a value from AWS SSM, if the key didn't exist or the application did not have access, we could fall back to the defaultValue, in this case the environment variable SOME_KEY.

In serverless@3, this behavior has changed. The defaultValue is no longer usable. Execution immediately stops if there is an AWS error.

NOTE: At first this was reported in the serverless-offline plugin, here: https://github.com/dherault/serverless-offline/issues/1278 but dnalborczyk said:

the variable resolution is done by serverless itself, which in turn also throws the error. I don't think there's much we can do about it.

... so I am reporting it here.

Service configuration (serverless.yml) content
SOME_KEY: ${ssm:/somepath/somekey~false, env:SOME_KEY}
Command name and used flags

serverless whatever

Command output
Error:
Cannot resolve serverless.yml: Variables resolution errored with:
  - Cannot resolve variable at "provider.environment.SOME_KEY": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: <http://slss.io/aws-creds-setup>.
Environment information
Framework Core: 3.21.0 (local)
Plugin: 6.2.2
SDK: 4.3.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the serverless.yml configuration and the serverless whatever command, using the reported Framework Core 3.21.0 environment. Trace the variable-resolution entry point responsible for provider.environment.SOME_KEY; done means an AWS SSM error or missing credentials no longer prevents the specified defaultValue fallback from being used.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.