dherault / dherault/serverless-offline
serverless offline does not work with aws: and ssm: variables
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 811
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
## Bug Report
It's **impossible** to work with serverless offline without connect to AWS if your `serverless.yml` file contains any variables which resolve from AWS (e.g. `${aws:accountId}` or `${ssm:/some/path}`).
You get errors like the following:
```
- Cannot resolve variable at "custom.key1": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
```
The only workaround I've seen is to put all such variables in a separate file - and have a separate file for every environment. This is cludgey, nasty, horrible ....
**Current Behavior**
```
❯ yarn exec -- sls offline start
yarn exec v1.22.19
Environment: darwin, node 16.17.0, framework 3.23.0 (local), plugin 6.2.2, SDK 4.3.2
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Cannot resolve serverless.yml: Variables resolution errored with:
- Cannot resolve variable at "custom.key1": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .,
- Cannot resolve variable at "custom.key2": AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: .
error Command failed.
Exit code: 1
Command: sls
Arguments: offline start
Directory:
Output:
info Visit https://yarnpkg.com/en/docs/cli/exec for documentation about this command.
```
**Sample Code**
- file: serverless.yml
```yaml
service: testcase
plugins:
- serverless-offline
provider:
name: aws
custom:
key1: ${aws:accountId}
key2: ${ssm:/some/path}
```
**Expected behavior/code**
It should work like this:
1. serverless-offline should have the common sense to not try to connect to an AWS service when running in offline mode - you shouldn't need to set `AWS_PROFILE` and configure dummy credentials in your .aws directory
2. by default it should replace these variables with a default value, e.g. `123412341234` for the `aws:accountId`
3. optionally it should be possible to override those default values via keys in the custom section of the serverless.yml
This is how plugins like `serverless-offline-ssm` and `serverless-pseudo-parameters` work.
But the recommendation seems to be to use the native serverless features instead, despite the fact that they just don't work offline !
**Environment**
Framework Core: 3.23.0 (local)
Plugin: 6.2.2
SDK: 4.3.2
** Further information **
This serverless-offline ticket was closed without action saying that this should be fixed in the core framework:
https://github.com/dherault/serverless-offline/issues/1278
This serverless ticket says that this is a problem with serverless-offline:
https://github.com/serverless/serverless/issues/11674
Someone needs to grab the bull by the horns on this one because the end user experience is that if you use the `aws:` variables recommended by the documentation, you simply can't use serverless offline without connecting to an AWS service of some kind.
Contributor guide
Assessment
This issue has not been assessed yet.