https://pulumi.com logo
f

full-dress-10026

10/18/2018, 9:38 PM
How do I pass an output to the build args of a
Service
? For example, I have
Copy code
export let apiEndpoint = deployment.invokeUrl.apply(url => url + deployment.stageName);

let nginxService = new cloudAws.Service("nginx", {
    containers: {
        nginx: {
            build: {
                context: "./nginx",
                args: {
                    "API_URL": apiEndpoint,
                    "FRONTEND_URL": frontendUrl
                }
            },
            memory: 256,
            ports: [{port: 443, external: true, protocol: "https"}]
        }
    },
    replicas: 3
});
But it appears build args requires a string, not an
Output
. In the above example,
apiEndpoint
is an output.
w

white-balloon-205

10/18/2018, 9:50 PM
Indeed - it looks like this API has not yet been updated to accept
Input<T>
for several inputs. So currently it may not be possible to do this. Opened https://github.com/pulumi/pulumi-cloud/issues/627 to fix this.
f

full-dress-10026

10/18/2018, 9:58 PM
Thanks. Is there any way to work around that for now?
w

white-balloon-205

10/18/2018, 10:25 PM
There's not a great way to work around it unfortunately. You can technically do something like:
Copy code
apiEndpoint.apply(endpoint => {
  let nginxService = new cloudAws.Service(...);
});
But creating resources inside an
apply
will lead to a couple potential issues: 1. Previews may not correctly track the creation of the resource. 2. The dependency of the
Service
on the
apiEndpoint
will not be set up correctly. This may mean that the initial deployment might fail, and you would need to retry. The right thing would be to enable this explicitly on the component though.
f

full-dress-10026

10/18/2018, 10:33 PM
Hmm ok. I'll experiment with those options to see what will best fit our setup. Yep, direct component support would definitely be best.