Given the following code, how can ensure that my o...
# aws
b
Given the following code, how can ensure that my outputs are evaluated prior to the resource creation that relies on it. The following does not appear to work..
Copy code
export const evaluateEnvironmentVariables = (services: Services, variables: Map<string, Output<string>>): void => {
    for (const service of services) {
        for (const envVar of service.environment) {
            const envVarName = envVar.name.toString();
            const replacementValue = variables.get(envVarName);

            if (replacementValue) {
                replacementValue.apply(value => {
                    envVar.value = value; // envVar.value is Input<string>, value is Output<string>
                });
            }
        }
    }
};

services.evaluateEnvironmentVariables(allServices, variables);

// Create resource that depends on these updated environment variables (KeyValuePair)
l
Can you pass the variables via constructor args instead of env vars?
Alternatively, you could try doing these things in the args of the resource? Haven't tried this though..
Copy code
new YourEnvVarResource(name, {
  services: pulumi.output(services).apply((services) => { /* your code */}),
  ...
});
In theory this would make your resources dependent on the
apply
, I think? So it wouldn't be created until that apply completed...
b
I'll give it a shot. thanks!