https://pulumi.com logo
Title
a

aloof-airport-42412

01/27/2022, 12:18 AM
Hello! I am new to Pulumi and apologize if this might be a stupid question Just trying Pulumi out with aws and having trouble with getting nested configuration in the code So I have below in my stack yaml file
autoscaling:environment:
  testEnv: testEnv
and I want to get it in typescript code
let config = new pulumi.Config();
let test = config.get("environment.testEnv");

console.log(`Environment Variable: ${test}`);
When I run
pulumi up
I get
Environment Variable: undefined
rather than the environment variable
l

little-cartoon-10569

01/27/2022, 12:29 AM
Is your project called "autoscaling"?
a

aloof-airport-42412

01/27/2022, 12:29 AM
yes
l

little-cartoon-10569

01/27/2022, 12:30 AM
So you could have
autoscaling:environment.testEnv: testEnv
What are you hoping to achieve?
a

aloof-airport-42412

01/27/2022, 12:34 AM
so I am looking at nested configuration because I want to have a bunch of environment variables under that. so
autoscaling:environment:
  testEnv: testEnv
  testEnv2: testEnv2
  testEnv3: testEnv3
I just don't know how to get the value of these in typescript code as in the above I have tried
config.get("environment.testEnv")
but It doesn't seems to be getting the value
l

little-cartoon-10569

01/27/2022, 12:36 AM
That set-up creates an object called environment with three properties. Is that what you want?
const environment = config.get("environment");
<http://pulumi.log.info|pulumi.log.info>(`${environmnet.testEnv} ${environment.testEnv2} ${environment.testEnv3}`);
Values are always of the form
<projectName>:<valueName>
, so you know that testEnv, testEnv2 etc. aren't values.
They're just properties on an object that is encoded in YAML.
a

aloof-airport-42412

01/27/2022, 12:40 AM
ahh I see, thank you