https://pulumi.com logo
#esc
Title
# esc
b

bored-king-84600

12/12/2023, 9:20 PM
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

plain-diamond-92898

12/12/2023, 10:31 PM
You can use multiple environments in your stack config. Can you share the error you are getting?
r

red-match-15116

12/13/2023, 12:38 AM
Yes, this should totally work as written. I'd be curious to hear what you're running into.
b

bored-king-84600

12/13/2023, 1:57 AM
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

red-match-15116

12/13/2023, 2:41 AM
b

bored-king-84600

12/13/2023, 8:28 PM