是否可以在不删除已有环境变量的情况下向AWS Lambda函数添加新的环境变量?
(就是使用命令行工具。)
答案 0 :(得分:1)
使用Lambda控制台,您只需附加新的环境变量即可:
使用CLI做到这一点更加困难-aws lambda update-function-configuration允许您有选择地更新lambda的各个方面,但是没有用于附加环境变量的辅助方法。您可以使用aws lambda get-function-configuration来获取环境变量的 current 列表。可以与某些bash / powershell脚本(或使用匹配的SDK函数选择的语言)结合使用。
例如:
const AWS = require('aws-sdk');
const lambda = new AWS.lambda();
const FunctionName = 'FUNCTION_NAME';
const AppendVars = { key: value };
async function appendVars() {
const { Environment: { Variables } } = await lambda.getFunctionConfiguration({ FunctionName }).promise();
await lambda.updateFunctionConfiguration({
FunctionName,
Environment: { Variables: { ...Variables, ...AppendVars } },
}).promise();
}
appendVars();
答案 1 :(得分:1)
我成功地将其用作bash脚本。
lambda函数的名称来自一个参数。我的目标是简单地更改变量,以便重新启动lambda函数。
MariaDB [(none)]> \s
--------------
mysql Ver 15.1 Distrib 10.1.40-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Connection id: 4
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.1.40-MariaDB-1~xenial mariadb.org binary distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 22 hours 38 min 44 sec
Threads: 1 Questions: 13 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.000
--------------
MariaDB [(none)]> show variables like '%ssl%';
+---------------------+--------------------------+
| Variable_name | Value |
+---------------------+--------------------------+
| have_openssl | NO |
| have_ssl | DISABLED |
| ssl_ca | |
| ssl_capath | |
| ssl_cert | |
| ssl_cipher | |
| ssl_crl | |
| ssl_crlpath | |
| ssl_key | |
| version_ssl_library | YaSSL 2.4.4 |
+---------------------+--------------------------+
10 rows in set (0.00 sec)