Hi! Is it possible to update a pulumi environment ...
# esc
l
Hi! Is it possible to update a pulumi environment programmatically? I want my stack to apply changes to my environment and was wondering if there was a typescript SDK for interacting with ESC? I can't seem to find any docs.
r
Officially, no. There is an open issue for this. However, I did play around with this recently and have some code that you could use to achieve this purpose. It may be a moment before this is supported officially - but I encourage you to try out the example code and let me know what you think. The test file is probably the best point of entry to real life usage.
Would love to get feedback if you do end up using it! It'll help guide our eventual efforts in this area!
l
We will definitely think about using it! We are also considering invoking the pulumi CLI from our stack, although it would be nicer to have a client like this one.
r
I'm curious if you think authoring makes more sense as a resource in the pulumiservice provider (since you mention invoking from your stack)
l
Essentially we have stackReferences between stacks, and reading the stack is the longest part of any pulumi up. We are hoping to decouple some of our stacks by having them push values to shared environments
r
Ah, you can already use stack references in environments with the pulumi-stacks provider. Do you mean that you would do this as part of the stack update? Like, this is my stack output, now also update the environment to include this stack reference?
l
So, our experience with running
pulumi up
is that reading the stack reference is very long. We actually have very few outputs from the stack that we need and they aren't that sensitive. We want to avoid having one stack pull in another. We are playing with the idea of creating a
dynamicResource
that will manage an environment we create to export certain stack outputs. We are hoping that loading a small environment will be much quicker than reading a stack. I saw that there's a pulumi-stacks provider but the documentation didn't seem to indicate that you can only import the outputs you want/need, or if it would be faster than using a StackReference in IaC. There's little value / difference for us whether a value comes from the config or a stack reference as long as we can decrease the time needed to run
pulumi up
r
I saw that there's a pulumi-stacks provider but the documentation didn't seem to indicate that you can only import the outputs you want/need, or if it would be faster than using a StackReference in IaC.
Oh interesting, yeah the esc provider returns all outputs from a stack. I think an original design did have the ability to only filter certain outputs. As for whether it's faster than using a StackReference in IaC - I'm actually not sure. And I'm surprised to hear accessing stack references is slow - that's probably something we want to look into!