【发布时间】:2018-07-18 06:51:32
【问题描述】:
我是使用无服务器框架的新手,我想检查 serverless.yml 中的环境变量是否根据我所处的阶段而变化。这是我在 serverless.yml 中的内容:
service: items
custom:
customDomain:
domainName: api.app.com
certificateName: '*.api.app.com'
basePath: ''
stage: ${self:provider.stage} <=== (Variable to check)
createRoute53Record: true
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
serverless-iam-roles-per-function:
defaultInherit: true
.......
provider:
name: aws
runtime: nodejs8.10
......
......
process_updates:
handler: handler.processUpdates
iamRoleStatements:
- Effect: "Allow"
Action:
- s3:*
Resource:
- "arn:aws:s3:::${file(./config.${self:provider.stage}.json):items_updates}/*"
Config.dev.json:
{
"items_updates": "dev-items-updates"
}
Config.prod.json:
{
"items_updates": "prod-items-updates"
}
所以,我想知道是否有办法打印以下变量
${self:provider.stage} 和 ${file(./config.${self:provider.stage}.json):items_updates} 进行部署时。是否有使用不同环境和无服务器框架的最佳实践?
提前致谢!
【问题讨论】:
标签: node.js serverless-framework