[英]How to set/update environment variables for a lambda function using Node SDK
I know I can specify environment variables when I'm creating a lambda function like this:我知道我可以在创建这样的 lambda 函数时指定环境变量:
var params = {
Code: { /* required */
ZipFile: new Buffer('...')
},
FunctionName: 'STRING_VALUE', /* required */
Environment: {
Variables: {
'<EnvironmentVariableName>': 'STRING_VALUE',
}
},
};
lambda.createFunction(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
But how can I set/update environment variables for a lambda function that already exists?但是如何为已经存在的 lambda 函数设置/更新环境变量? I don't see any parameter for updateFunctionCode !
我没有看到updateFunctionCode 的任何参数!
There's a separate API call for updating the lambda runtime config, including the environment.有一个单独的 API 调用用于更新 lambda 运行时配置,包括环境。
https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionConfiguration.html https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionConfiguration.html
It also updates the timeout, memory, dead letter queue, etc.它还更新超时、内存、死信队列等。
After you've changed the environment variable in the console, you can run在控制台中更改环境变量后,您可以运行
aws lambda update-function-configuration --function-name <YOUR_LAMBDA_NAME> --memory-size <YOUR_LABMDA_MEMORY_LIMIT_DEFAULT_128MB>
I don't see the option to execute this command from AWS Console, which is pretty odd.我没有看到从 AWS 控制台执行此命令的选项,这很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.