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

migrate api_shield_operation to framework #4894

Conversation

BrendanBall
Copy link

This PR migrates cloudflare_api_shield_operation to the terraform-plugin-framework to fix a bug caused by the API returning a normalized version of a specified attribute that causes mismatches between resource config and state, resulting in the resource having to be recreated on every terraform apply. This is due to not following the expectations of terraform mentioned in https://github.com/hashicorp/terraform/blob/main/docs/resource-instance-change-lifecycle.md:

Normalization: the remote API has returned some data in a different form than was recorded in the Previous Run State, but the meaning is unchanged.
In this case, the provider should return the exact value from the Previous Run State, thereby preserving the value as it was written by the user in the configuration and thus avoiding unwanted cascading changes to elsewhere in the configuration.

Migrating to the framework is necessary to implement semantic equality between the unnormalized config and the normalized state returned from the API which is used during terraform plan/apply.

Copy link
Contributor

github-actions bot commented Jan 16, 2025

changelog detected ✅

@BrendanBall BrendanBall force-pushed the api-shield-operation-framework-migration branch from 23e3a5e to d7c2be0 Compare January 16, 2025 08:26
Copy link

@maciej maciej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, left one comment, though.

(I can't approve because of lack access)

@BrendanBall BrendanBall force-pushed the api-shield-operation-framework-migration branch from d7c2be0 to 595774b Compare January 16, 2025 16:15
@jacobbednarz
Copy link
Member

acceptance tests all passing

TF_ACC=1 go test ./internal/framework/service/api_shield_operation/ -run "^TestAcc" -count 1 -v
=== RUN   TestAccCloudflareAPIShieldOperation_Create
--- PASS: TestAccCloudflareAPIShieldOperation_Create (5.73s)
=== RUN   TestAccCloudflareAPIShieldOperation_ForceNew
--- PASS: TestAccCloudflareAPIShieldOperation_ForceNew (8.44s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/api_shield_operation     15.876s

@jacobbednarz jacobbednarz merged commit 402ea54 into cloudflare:master Jan 20, 2025
2 checks passed
@github-actions github-actions bot added this to the v4.51.0 milestone Jan 20, 2025
@BrendanBall
Copy link
Author

Thanks @jacobbednarz

Copy link
Contributor

This functionality has been released in v4.51.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants