how can i move a stack from one org to another?
# general
d
how can i move a stack from one org to another?
b
It's a little hacky today, but you should be able to do the following: 1. Export the stack with
pulumi stack export
2. Create a new stack with the same name in the target organization
pulumi stack init <org-name>/<stack-name>
3. Import the stack you exported with
pulumi stack import
4. Since secret configuration is encrypted with a key tied to the stack itself, you'll have to (unfortunately) run
pulumi config set --secret <key> <value>
to reset any encrypted configuration you have. 5. You should now be able to
pulumi stack rm
the old stack. You don't want to run
pulumi destroy
.
d
ok - will give it a shot
oh - what if i want to rename it too? is that a separate step?
b
This will be a little trickier. Since the URN of every resource includes both the stack name (sans organization) and project it is in, you'll have to manually export the stack and then edit the checkpoint to rename the stack name in the URN. and then import the new checkpoint, So between 2 and 3, edit the checkpoint you exported and replace
urn:pulumi:<old-stack-name>::
with
urn:pulumi:<new-stack-name>::
. @microscopic-florist-22719 Does that sound right to you?
m
I think so, yes. Note that the
import
will refuse to proceed if the stack name is incorrect, so at the very least we have belt and suspenders here.
d
this UX is pretty bad - creating the new stacks overwrote my config files
luckily i was able to
git checkout
to get them back
or maybe i was just confused? i’m not sure what happened
got it sorted - will do the rename soon
thanks
oh yeah, removing the stack deletes the config file
reaaaally should not do that
especially if the file is dirty
maybe suggest it in the output?
ugh, now i need to go recover the secrets from elsewhere
i luckily ran config --show-secrets not too long ago
but how do i backup my secret key for later?
b
but how do i backup my secret key for later?
There's no concept of that today. The kye is created when a stack is initialized and managed by the service for the lifetime of the stack.
d
sigh this did not go well
i have two stacks and somehow didn’t properly stack export one of them
i removed the old stack before importing it
is there any way to recover it?
m
we can help you out here, yes.
d
thank you!
whew.
m
can you DM me the name of the deleted stack?
d
yes, thanks