When renaming stacks (`pulumi stack rename`), what...
# getting-started
p
When renaming stacks (
pulumi stack rename
), what is the best way of updating other stacks that have
StackRefrences
to the original name of the renamed stack? There doesn't look to be an update for those stacks.
s
Correct, you’ll have to update stack references manually. I usually recommend making the stack name a configuration parameter you can pass into your program via
pulumi config set
to simplify this process. We talk a bit about this idea in our blog post on recommended practices for stack references: https://www.pulumi.com/blog/iac-recommended-practices-using-stack-references/
p
Thanks, @salmon-account-74572 - What's the process for the manual update? Does that imply manually editing the name within the JSON? (And how would that avoid interacting with the magic number in the manifest)
s
If memory serves correctly, the URNs in the referring stack use the name of the stack reference object, and don’t refer directly to the original/source stack. So as long as you don’t change the name of the stack reference object in your code, then a
pulumi up
should show no changes. (It’s been a bit since I tested this scenario, so I may be mistaken.)
p
Thanks... that makes sense. FWIW, what I did see is that if a rename a stack, then
pulumi refresh
on a referring stack will fail because it can't find the renamed stack. I'll read through what you linked and work through a few more scenarios here.
s
Let me know if you run into additional questions, we’re happy to help.
p
Thanks again... I think my particular instance of this issue might be unusual. We have a couple self-hosted backends and recently created a few more. Some were created before project scoped stack support was added and some after. (So they have different rules for parsing stack names, and I had to update stack names to work in the newer backends)
Combine that with the fact I didn't parameterize the stack names.... 😞
s
Gotcha. If we can help further, please let us know.