Why does `pulumi refresh` not update the stack sta...
# azure
p
Why does
pulumi refresh
not update the stack state to reflect the resources that exist in the target environment but which do not exist in the stack?
More than once I have ended up in this situation, when a deployment goes wrong and the resource exists in Azure but Pulumi thinks the deployment fails so it doesn’t create the resource in the stack state.
How can I import these resources into the state, so Pulumi stops trying to re-create them?
p
Interesting, didn’t know about this. Thanks!
But it doesn’t seem 100% appropriate.. I mean, these are resources that Pulumi itself created.
The fact that they are not in the stack should be addressed with refresh rather than specifying in code that they should be imported.
Seems weird to have to go and change the code to account for an inconsistent state.
c
I agree, unfortunately I think that's also a problem in TF. I've seen deployments "fail" (but not fail) and then the state is inconsistent. So you either have to manually edit the state file or do the import. 😞
p
I see.
And where does this state file live?
c
depends, are you using the service or a storage account you manage? You can get your state file either way using https://www.pulumi.com/docs/reference/cli/pulumi_stack_export/
p
OK, will check it out! Thanks for the quick response! 👍
c
no worries 🙂
t
The problem is that if the creation API call fails, there’s no obvious way to know that the actually created resource is ours. I suppose we could have some heuristics but they may be hard to get right across all providers.
p
@tall-librarian-49374 I see your point.