https://pulumi.com logo
Title
t

thousands-pizza-93362

11/23/2022, 8:00 PM
Hey guys, quick question: I have a resource defined in one stack (an AWS vpc) - I want to move it from this stack to another stack. Is there a way to do that without deleting the resource when I delete the code in the initial stack?
l

little-cartoon-10569

11/23/2022, 8:03 PM
Stack? Do you mean project?
t

thousands-pizza-93362

11/23/2022, 8:03 PM
Sorry, yeah
Project
l

little-cartoon-10569

11/23/2022, 8:04 PM
Great. Then you can use
pulumi import
, or else copy the code from the old project to the new one, and add the
import
opt. The value to put in the opt is described at the bottom of the resource's API docs page.
Once it's successfully imported, go back to the other project, remove the code for the resource, run
pulumi state delete
on the resource, and then check all is well by running
pulumi preview
.
t

thousands-pizza-93362

11/23/2022, 8:06 PM
Awesome. Thank you!
l

little-cartoon-10569

11/23/2022, 8:06 PM
If you use the
import
opt, don't forget to remove that opt from code once it's imported.