serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
Variable references used in service.provider.stage are literally passed through
trafficstars
Actual Behaviour
I have following configuration in serverless.yml:
# plugins
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-offline
custom:
stages:
- local
- development
- production
# default stage/environment
defaultStage: local
...
# aws provider
provider:
name: aws
...
stage: ${opt:stage, self:custom.defaultStage}
....
when I use below command, the hooks are not getting registered.
npx serverless dynamodb install
But, when I use below one, it works:
npx serverless --stage local dynamodb install
Expected Behaviour
If the configuration uses variables, then should be resolved using default stage.
Steps to reproduce it
- configure serverless project as per above configuration
- try install command
LogCat for the issue
$ npx serverless dynamodb start
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command webpack
Serverless: Load command dynamodb
Serverless: Load command dynamodb:migrate
Serverless: Load command dynamodb:seed
Serverless: Load command dynamodb:start
Serverless: Load command dynamodb:noStart
Serverless: Load command dynamodb:remove
Serverless: Load command dynamodb:install
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke dynamodb:start
Serverless: Warning: The command you entered did not catch on any hooks
Screenshots of the issue
Where-ever possible attach a screenshot of the issue.
Would you like to work on the issue?
Yes. I have went through #142, but it not taking care of the above situation.
Below code is used while construction of plugin and thus service.provider.stage with variable reference is not resolved correctly. We need to move this post construction of the plugin.
const stage = (this.options && this.options.stage) || (this.service.provider && this.service.provider.stage);
if (this.config.stages && !this.config.stages.includes(stage)) {
// don't do anything for this stage
this.hooks = {};
return;
}