https://pulumi.com logo
#azure
Title
# azure
p

powerful-football-81694

03/22/2020, 2:55 AM
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

powerful-football-81694

03/22/2020, 3:10 AM
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

colossal-room-15708

03/22/2020, 3:16 AM
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

powerful-football-81694

03/22/2020, 3:17 AM
I see.
And where does this state file live?
c

colossal-room-15708

03/22/2020, 3:18 AM
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

powerful-football-81694

03/22/2020, 3:19 AM
OK, will check it out! Thanks for the quick response! 👍
c

colossal-room-15708

03/22/2020, 3:19 AM
no worries 🙂
t

tall-librarian-49374

03/22/2020, 10:08 AM
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

powerful-football-81694

03/22/2020, 10:44 AM
@tall-librarian-49374 I see your point.
3 Views