Hey folks, I have question regarding the `Pulumi.y...
# general
m
Hey folks, I have question regarding the
Pulumi.yaml
config file: I understand that it's used to keep configs about the environment, name of the project etc.. and at the same time to set configs that are not dependant on the stack. However, regarding the 2nd part, I am wondering: isn't it just the same as creating a
config.py
file and just setting global variables there? What is the advantage of setting them in
Pulumi.yaml
?
l
Yes, you can set your variables any way you like, and access them from your code accordingly. Many Pulumi features are just Pulumi-specific solutions which you can implement in a different way. An advantage to using the project-wide variables is that a single API (and indeed, a single config object) can be used to to get all those values. If you used env vars or any other solution, you'd have to know which variables are accessed from Pulumi config, and which from those other places.
It also means that if your project-wide value becomes stack-specific in the future, you don't need to re-implement anything. Just remove the value from the Pulumi.yaml file, and put it in all your Pulumi.stack.yaml files.
m
yeah fair enough, thanks for the explanation @little-cartoon-10569. Usually what I do is create a
config.py
file anyway, where I load all the pulumi configs there, and then import them in separate pulumi modules as needed. So I only have to write once
configs = pulumi.Config()
etc...
c
From top of my head: • Stack config is used to parametrize [otherwise similar] deployments. • Values in Pulumi.yml provide defaults for stack config when they are not specified per stack but are required. It also serves as a documentation describing which values to expect. • Stack config can contain secrets • Stack config is a serializable in Key-Value and can round-trip between different languages. This is important if you use Pulumi automation with different languages. • YAML language can't use
config.py
. • Config can be queried by providers (which run in a different process)