Hello folks, Need to understand about the state of...
# aws
a
Hello folks, Need to understand about the state of the stack. if i delete one or more resource from the existing stack, and when i run Pulumi up again, it doesn’t identify the deleted resources and create them again. Is that really possible if it identifies the state of the stack and create the deleted resources again?
l
If you delete them from the stack, then the resources still exist, but Pulumi will try to create them again. This may cause a conflict, depending on how you've named things.
If you delete them from the provider and not from the stack, then you need to refresh the stack from the provider before Pulumi detects the change. Once you've done that, Pulumi will recreate the resource.
If you delete something from both the stack and the provider, then Pulumi will recreate it.
I have inferred from your question that you may be conflating the stack and the provider. The stack is Pulumi's idea of what exists, which may be different from what actually exists.
a
That make sense to me, So i always have to refresh the stack in order to pulumi know about the deleted resources, than only pulumi re-creates one.
l
Yes. You can use
pulumi up --refresh
as a shortcut.
a
Because what i did here is, i removed the resource manually from AWS UI and ran the pulumi up again, where pulumi doesn’t know which resources were deleted.
l
It is generally better to fully manage things through Pulumi, if possible. Don't delete things through the provider directly.
1
a
Right i got it, I ran refresh on stack and it worked. So ultimate thing is, we always have to run the refresh to run the pulumi if resources are deleted or terminated manually.
✔️ 1
Right, i agree with you, But i am thinking of an scenario where other folks delete accidentally and if i want to maintain a state, but agreeing your statement on refreshing stack is works.
l
Yes. It's not always possible to fully manage through Pulumi. Just a goal 🙂
a
That make sense, agree to your words.
I appreciate your help and sharing knowledge.
👍 1