如何为环境变量向 Pulumi 输出添加条目?

问题描述

我已经为 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,},