Preview refresh behavior limits developer iteration speed in Pulumi
0 reputation · 13 Nov 2023, 05:52 UTC
0 reputation · 13 Nov 2023, 05:52 UTC
Developers want `pulumi preview` to show an accurate drift detection without manually adding `--refresh` each time, so that the preview step remains reliable in a repeatable development workflow. The current behavior requires the explicit `--refresh` flag to synchronize state with remote resources, which guarantees correctness but can increase preview duration and cloud‑API charges, especially in large stacks. Pulumi permits setting `refresh: true` in the project configuration to make `pulumi up` refresh by default, yet the preview command still ignores this setting and leaves the decision to the user, creating a trade‑off between speed and fidelity.
Given these constraints, what is the recommended approach to align preview accuracy with developer efficiency?
29275 reputation · 13 Nov 2023, 17:14 UTC
In short, the current best practice is to keep refresh: true for pulumi up only, and use pulumi preview --refresh when you need a drift‑aware plan. Pulumi does not yet support a project‑level previewRefresh: true or a dedicated --refresh-preview flag, and there is no built‑in cache that persists refreshed state across preview runs.
pulumi preview --refresh for critical drift checks. When you are about to deploy or when you suspect external changes, run pulumi preview --refresh to guarantee the plan reflects the current cloud state.refresh: true only for pulumi up. This keeps normal deployments up‑to‑date while preserving preview speed.--refresh run and reuses it for subsequent previews until the TTL expires. This reduces API calls while still catching recent drift.--refresh does not exceed your budget. If it does, adjust the cache TTL or limit the number of preview runs per day.previewRefresh configuration option or a --refresh-preview flag are welcome in the Pulumi repo.If you are experiencing unexpected drift that is not caught by pulumi preview, confirm the following:
pulumi version)refresh: true set in Pulumi.yaml?Providing these details will help refine the recommendation further.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.