Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not update Azure resource if only AzApi-specific meta-properties are changed (e.g. retry, lock) #723

Open
cwe1ss opened this issue Jan 14, 2025 · 7 comments
Labels
enhancement New feature or request

Comments

@cwe1ss
Copy link

cwe1ss commented Jan 14, 2025

Whenever we have to fine-tune the retry error messages, the locks-property (or any other AzAPI meta-property), all existing resources in all our terraform stacks show changes and execute updates to their underlying Azure APIs, even though nothing has actually changed about the resources. This is slow and results in many unnecessary Azure requests.

Is there any way for AzApi to fully ignore these changes (showing "No changes" in a terraform plan-step), or at least not execute a call to the underlying Azure API in the terraform apply-step?

@stemaMSFT
Copy link
Member

Thanks for this issue @cwe1ss this does seem like a bug with the provider. Are you only fine-tuning for one resource and seeing changes across all the resources configured?

@cwe1ss
Copy link
Author

cwe1ss commented Jan 14, 2025

It only affects the resource where we set it. But since we set the retry-property on many resources, and since we use our modules in many terraform stacks, it often results in many changes.

@stemaMSFT
Copy link
Member

Gotcha! Have you set lifecycle ignore changes on the property?

lifecycle {
    ignore_changes = [retry, timeouts]
}

I know this adds more code, but it should suppress any state diff that is caused from this.

@cwe1ss
Copy link
Author

cwe1ss commented Jan 14, 2025

Will using ignore_changes still use the most recent version of the set value in the next apply?

E.g., if I've initially set retry.error_message_regex to ["a"], and later change it to ["b"], will the next real apply use a or b?

@stemaMSFT
Copy link
Member

Your next apply will not set the value to ["b"] as it will ignore updates to the resource property but still create with that property set (if specified): https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#ignore_changes do you want to change the property's value but not have it show in state?

@ms-henglu
Copy link
Member

Hi all,

I think it's better to improve the azapi's behavior that changing the azapi meta-properties won't trigger the http request.

@ms-henglu ms-henglu added the enhancement New feature or request label Jan 16, 2025
@matt-FFFFFF
Copy link
Member

See #745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants