How do I get environment variables that I set on t...
# general
l
How do I get environment variables that I set on the Pulumi website (not the local config)? This is my code, but it doesn't work:
Copy code
const deploymentSettings = new pulumiservice.DeploymentSettings("my-deployment-settings", {
    sourceContext: {},
    stack: stackName,
    organization: organization,
    project: projectName
});

const envVariables = deploymentSettings.stack.apply((opCtx: any) => opCtx);

envVariables?.apply((id: string) => {
    console.log(`ok  ok   GOOGLE_CLIENT_ID='${id}'`);
});
I also tried this, but it just returned undefined (yes, I already have that value defined on the deployment settings on the pulumi website):
Copy code
const stackReferenceName: string = `${organization}/${projectName}/${stackName}`;
const stackReference: pulumi.StackReference = new pulumi.StackReference(stackReferenceName); 
const googleClientId2 = await stackReference.getOutputValue("GOOGLE_CLIENT_ID");
l
The documentation for DeploymentSettings (https://www.pulumi.com/registry/packages/pulumiservice/api-docs/deploymentsettings/) suggests that you may be able to get at the environmentVariables via deploymentSettings.operationContext.environmentVariables, though I haven't tried that myself. FYI there is a #pulumi-deployments channel that is focused specifically on this topic.
To "debug", you could try something like this:
Copy code
deploymentSettings.operationContext.environmentVariables.apply((vars) => {
  for (key of vars) {
    pulumi.log.info(`${key} is ${vars[key]}`);
  }
});
(Untested)
l
@little-cartoon-10569 Property 'operationContext' does not exist on type 'DeploymentSettings'
l
Ah. The documentation is incorrect. I've checked the SDK, and operationContext is available only as an Input. The docs say "All input properties are implicitly available ask output properties" but that's obviously not true. So that's a documentation bug! It looks like you cannot get at the values then. They are not exposed through the SDK. Someone over in #pulumi-deployments might know better though, so you might check there.
l
i'll try them