使用以下 AWS SAM 模板 process.env 是一个空对象。我希望它包含定义为 dbURL 的模板中的环境变量。
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Description: "An example RESTful service"
Resources:
ExampleFunction:
Type: "AWS::Serverless::Function"
Properties:
Runtime: "nodejs6.10"
Handler: "/dist/getTickets/index.handler"
Events:
RootDeveloperHub:
Type: "Api"
Properties:
Path: "/new"
Method: "any"
Environment:
Variables:
dbURL: "dbURL_Value"
处理程序
exports.handler = (event, context, callback) => {
// logs {}
console.log(process.env)
}
我已经排除的事情:
- webpack react process.env 始终为空(Windows 10) - 我没有 DefinePlugin 配置。我也在用mac。