This message was deleted.
# general
s
This message was deleted.
b
If you wanted to use Pulumi config, you could have a project / stack that was just configuration, output all the config values and then consume them as stack references in other projects/stacks
g
what if I want to have common config within 1 service (common to all stacks but specific to 1 service). I would like to keep this common config inside the service, not in separate project
e
Yes, that would work but I was hoping that I could do this without creating a new project/stack for each project. I also took a closer look at the automation api and doesn't look like I can use this when using the pulumi cli.
b
The other way would be to make use of the fact you're writing code and have a package that had a load of constants in it that you could share
e
that's an option we've considered for configurations that go across all projects. what would be nice is to be able to see these configs in the pulumi console for auditing, debugging, etc.. i guess there isn't a way to currently do this?
the problem is not being able to use shared configs but getting them in the console. i can create a github issue with this request if the capability is currently not there.
b
I would always suggest creating an issue if we're not allowing you do what you want, and this isn't the first time I've spoken about cross-stack config
e
i believe there is already an issue about this: https://github.com/pulumi/pulumi/issues/2307 and one for configs in general: https://github.com/pulumi/pulumi/issues/4604 but i will create one specifically for being able to set configs from the Config class.
b
You can set config in the config class for the stack you're in
Sorry, I missed that at the beginning
Sorry, no you can't
not in "normal" code
You can in automation api
e
but i don't think you can use this api at the same time you runnig your program from the pulumi cli?
b
You can run pulumi programs through the automation api, but you're right about the CLI
👍 1
e
g
Hi Piers, it looks like pulumi insists on presents of Pulumi.stack.yaml ( for example Pulumi.dev.yaml) be present when 'pulumi up' called. We want to generate this file at runtime. I tried to create this file as a first step the pulumi script, before calling new pulumi.Config();, but it's already too late, it picks values already there. Is there a way to enforce pulumi to reload values before continue with deployment?
b
You can have an empty stack config file, there doesn't have to be anything in it
e
What we wanted to do is dynamically create the Pulumi.dev.yaml. Our pulumi program reads in a config.common.yaml and a config.dev.yaml files and then merges these two files together and then writes it to Pulumi.dev.yaml. We then read the configs by calling new pulumi.Config(); We were hoping it would read the new stack config file we created but it looks the Config class uses the stack configs that were present when pulumi up was called and ignores the file that we created.
if looks like if we want to leverage the pulumi.Config api for reading in stack configs we need to generate the Pulumi.[stack].yaml file before we call pulumi up.
it would be nice if you could have a pre-pulumi-up hook that executes before the pulumi up code. I guess you could do this with the automation api but it seems overkill for just this use case.
g
here is more details:
Pulumi.dev.yaml does not exist before run. When run first we create this file and dump content of it to console. Only after that we call 'new pulumi.Config()'.
at that point Pulumi.dev.yaml file is in place and has correct values. Wehn we run 'pulumi up' second time it will use it and it works fine. Here is cleaned up (hello world type) code
it looks like when pulumi starts it loads Pulumi.dev.yaml before new pulumi.Config() called. Is it possible to force it to reload configs?
b
Have you looked at Automation API? I don't think what you're asking is possible outside of that.
g
Thanks. I will check
e
Using the automation API you lose all the features of the CLI as well as all the third party integrations. I found this issue that documents some of the shortcomings: https://github.com/pulumi/pulumi/issues/5538 and suggests a solution: https://github.com/pulumi/automation-api-examples/tree/main/go/inline_local_hybrid which we will look at.