Hi there! I'm super new to Pulumi (today is my fir...
# dotnet
b
Hi there! I'm super new to Pulumi (today is my first time using it) and I'm not sure if this question should go here or somewhere more general. I'm still trying to figure out how the
Pulumi.<some-name>.yaml
files work. Right now, I'm doing an experiment and created three separate yaml files:
Pulumi.yaml
Pulumi.dev.yaml
Pulumi.prod.yaml
I added a specific variable to the
Pulumi.dev.yaml
and
Pulumi.prod.yaml
ones called
app:environment
(setting the values to
dev
and
prod
, respectively) and then added this bit of code to my stack class so I can see the output:
Copy code
var config = new Config();
var env = config.Require("app:environment");
Console.WriteLine(env);
Now, when I run
pulumi up
for my
dev
stack, it gives me the following error:
Copy code
Missing Required configuration variable 'dotnettestservice:app:environment'
It looks like it's looking for it in
Pulumi.yaml
, not
Pulumi.<env>.yaml
. I have
dotnettestservice
defined under the
name:
parameter in my
Pulumi.yaml
, not in
Pulumi.dev.yaml
, nor
Pulumi.prod.yaml
. When I do a
pulumi config get app:environment
, it gives me the correct value of
dev
. My question is, am I allowed to have different required parameters based on the stack? Do I have to have a separate
name
parameter in each of these so it doesn't try to use the
Pulumi.yaml
one? Also, feel free to let me know if I'm not making sense and need to clarify anything (or if I'm going about this the completely wrong way) 😅 I appreciate any insight you might have ❤️
I was looking through the docs and some GitHub issues, but still wasn't able to find a clear answer to this. I did attempt to use the namespace name in
new Config()
as well, but it seemed to be looking in the correct one originally as well 🤔
t
Hi Olga, welcome! Every config value is prefixed with a namespace. The default namespace is the same as you project name. So,
new Config
looks for config values named
dotnettestservice:foo
. You should either a) Change you
yaml
files to contain settings called
dotnettestservice:environment
b) Leave the config files as-is and change your code to
var config = new Config("app"); config.Require("environment");
❤️ 1
You can use the Pulumi CLI to set config values.
pulumi config set environment test
will automatically add the project name to the YAML file. Give it a try.
b
🤦‍♀️ That makes so much sense. I definitely misinterpreted the documentation. It worked 😄 THANK YOU!
t
I feel like it’s a common misunderstanding. We should probably improve our docs. Feel free to fire an issue if you see a part that’s particularly confusing. For sure, don’t feel bad about yourself!