如何为环境变量向 Pulumi 输出添加条目?
How to add entries to Pulumi output for environment variables?
我在 Pulumi 中为环境变量创建了一个 Output
,就像 https://github.com/pulumi/examples/blob/master/aws-ts-airflow/index.ts#L61 一样,但我需要为我正在启动的其中一个容器向这些环境变量添加一个条目。
我想在声明类似于 https://github.com/pulumi/examples/blob/master/aws-ts-airflow/index.ts#L79-L85
的容器时做一些事情
"webserver": {
image: awsx.ecs.Image.fromPath("webserver", "./airflow-container"),
portMappings: [airflowControllerListener],
environment: environment + {name: "ANOTHER_ENV", value: "value"},
command: [ "webserver" ],
memory: 128,
},
我试过 pulumi.all
(pulumi.all([environment, {name: "FLASK_APP", value: "server/__init.py"}])
) 和 environment.apply
,但一直无法弄清楚如何联系 Output
。
这可能吗?如果是,怎么做?
你应该可以
const newEnvironment = environment.apply(env =>
env.concat({ name: "ANOTHER_ENV", value: "value"}));
// ...
"webserver": {
image: awsx.ecs.Image.fromPath("webserver", "./airflow-container"),
portMappings: [airflowControllerListener],
environment: newEnvironment,
command: [ "webserver" ],
memory: 128,
},
我在 Pulumi 中为环境变量创建了一个 Output
,就像 https://github.com/pulumi/examples/blob/master/aws-ts-airflow/index.ts#L61 一样,但我需要为我正在启动的其中一个容器向这些环境变量添加一个条目。
我想在声明类似于 https://github.com/pulumi/examples/blob/master/aws-ts-airflow/index.ts#L79-L85
的容器时做一些事情 "webserver": {
image: awsx.ecs.Image.fromPath("webserver", "./airflow-container"),
portMappings: [airflowControllerListener],
environment: environment + {name: "ANOTHER_ENV", value: "value"},
command: [ "webserver" ],
memory: 128,
},
我试过 pulumi.all
(pulumi.all([environment, {name: "FLASK_APP", value: "server/__init.py"}])
) 和 environment.apply
,但一直无法弄清楚如何联系 Output
。
这可能吗?如果是,怎么做?
你应该可以
const newEnvironment = environment.apply(env =>
env.concat({ name: "ANOTHER_ENV", value: "value"}));
// ...
"webserver": {
image: awsx.ecs.Image.fromPath("webserver", "./airflow-container"),
portMappings: [airflowControllerListener],
environment: newEnvironment,
command: [ "webserver" ],
memory: 128,
},