pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
199 stars 43 forks source link

Automatically run pulumi refresh after each step #2613

Open KnockOutEZ opened 1 week ago

KnockOutEZ commented 1 week ago

Hey, I'm using the pulumi-terraform-bridge provider in my Pulumi project, and I'm looking for a way to automatically run pulumi refresh after each step, similar to how Terraform automatically refreshes the state. In Terraform, when you apply changes, it automatically runs terraform refresh to ensure the state file accurately reflects the current infrastructure. This is a helpful behavior that ensures the state is always in sync. I'd like to see if there's a way to achieve the same behavior in the pulumi-terraform-bridge provider. Is there an option or configuration I can use to automatically run pulumi refresh after each pulumi up or pulumi destroy step? Alternatively, would it be possible to add this as a feature in a future release of the pulumi-terraform-bridge provider? Having the ability to automatically refresh the state would greatly improve the workflow and help prevent any state drift issues. Please let me know if you have any suggestions or insights on how I can achieve this. I'm happy to provide more context or work with the team to implement a solution.

VenelinMartinov commented 1 week ago

Hey @KnockOutEZ thanks for the question! I believe that Terraform refreshes the state before each action. You can emulate the same behaviour with --refresh in pulumi, like so pulumi up --refresh. This should ensure that pulumi has the latest state for your resources before running the program.

KnockOutEZ commented 1 week ago

Hey @VenelinMartinov thanks for the reply! Is there any way to enforce this programmatically into the provider so even if the customers dont run pulumi --refresh it will still refresh the state by itself.

VenelinMartinov commented 1 week ago

Hey, no, we currently have no way to specify that a provider should refresh by default. What is the use case you have for this? Why does the provider you are bridging require --refresh?