How Pulumi match a state? For example, if one reso...
# general
b
How Pulumi match a state? For example, if one resource is already provisioned, how will it know next time that you run it that it does not try to recreate it?
l
It maintains a state file. So there are three truths: your code (future state), Pulumi's state (most recent deployment / refresh), and cloud state (current state). You use
up
to push code to cloud via state; you use
refresh
to update state from cloud; and
preview
to detect changes between code and state. Pulumi uses the differences between code and state to make changes to cloud; when those succeed, state is updated; and when they fail, you need to diagnose and remedy (usually, via
refresh
).
It is important to acknowledge that Pulumi is not imperative: a resource constructor does not equate to "deploy this resource". It is declarative: a resource constructor means "ensure this resource is deployed".
l
A good starting point is our How Pulumi Works article in the docs.