Is it only possible to set one environment in your...
# esc
b
Is it only possible to set one environment in your stack config? Wanted to do something like below but running into undefined when more than one environment is set
Copy code
# Pulumi.dev.yaml
environment:
  - api-auth-dev
  - api-billing-dev
  - api-documents-dev
config:
  aws:profile: dev
  aws:region: ap-southeast-2
  ...
p
You can use multiple environments in your stack config. Can you share the error you are getting?
r
Yes, this should totally work as written. I'd be curious to hear what you're running into.
b
The configs in api-auth-dev and api-billing-dev were both undefined and it seems to be because the api-documents-dev environment had an import. I’ve proved this out with a simple example Environments:
Copy code
# env-a
values:
  pulumiConfig:
    foo: env-a-config
Copy code
# env-b
values:
  pulumiConfig:
    bar: env-b-config
Copy code
# Pulumi.dev.yaml
environment:
  - env-a
  - env-b
config:
 ...
Copy code
// index.ts

const config = new pulumi.Config();

console.log(`config.get("foo"): ${config.get("foo")}`)
console.log(`config.get("bar"): ${config.get("bar")}`)
Output:
Copy code
pulumi:pulumi:Stack (myhr-fullenv-dev):
    config.get("foo"): env-a-config
    config.get("bar"): env-b-config
This works as expected - but now if I import something in env-b, env-a will become undefined.
Copy code
# env-b
imports:
  - env-c-secrets
values:
  pulumiConfig:
    bar: env-b-config
Copy code
# env-c-secrets
values:
  password: 12345
And run the code again this is my output:
Copy code
pulumi:pulumi:Stack (myhr-fullenv-dev):
    config.get("foo"): undefined
    config.get("bar"): env-b-config
Hope this example makes sense - I’ve found a work around by just creating a kind of super env that imports everything I need and then setting that as the only environment in my stack so not a big deal but curious to know if this is a bug or just some edge case I’ve stumbled on 🙂
r
b