Search code examples
pulumi

How to add entries to Pulumi output for environment variables?


I've created an Output for environment variables in Pulumi just like https://github.com/pulumi/examples/blob/master/aws-ts-airflow/index.ts#L61 but I need to add one entry to these env vars for one of the containers I'm spinning up.

I'd like to do something like when declaring a container similar to 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,
            },

I've tried playing around with pulumi.all (pulumi.all([environment, {name: "FLASK_APP", value: "server/__init.py"}])) and environment.apply but haven't been able to figure out how to contact to an Output.

Is this possible? If so, how?


Solution

  • You should be able to

    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,
    },