BunnyWay / terraform-provider-bunnynet

bunny.net Terraform provider
https://registry.terraform.io/providers/BunnyWay/bunnynet
Mozilla Public License 2.0
6 stars 1 forks source link

custom_404_file_path error #8

Closed pwilczynskiclearcode closed 1 month ago

pwilczynskiclearcode commented 2 months ago

I can't nullify the custom_404_file_path of a storage zone:

    resource "bunnynet_storage_zone" "permanent-logs" {
      name      = "permanent-logs-staging"
      region    = "NY"
      zone_tier = "Standard"
      custom_404_file_path = null
    }

plans shows

  # bunnynet_storage_zone.permanent-logs will be updated in-place
  ~ resource "bunnynet_storage_zone" "permanent-logs" {
      - custom_404_file_path = "/404.html" -> null
      ~ date_modified        = "2024-09-04T09:46:33" -> (known after apply)
        id                   = ....
        name                 = "permanent-logs-staging"
        # (6 unchanged attributes hidden)
    }

but apply fails:

bunnynet_storage_zone.permanent-logs: Modifying... [name=permanent-logs-staging]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to bunnynet_storage_zone.permanent-logs, provider "provider[\"registry.terraform.io/bunnyway/bunnynet\"]" produced an unexpected new value: .custom_404_file_path: was null, but now cty.StringVal("/404.html").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

The resource was initially imported using terraform import

pwilczynskiclearcode commented 2 months ago

Similar issues:

╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to bunnynet_pullzone_edgerule.block_paths["efg"], provider "provider[\"registry.terraform.io/bunnyway/bunnynet\"]" produced an unexpected new value: .triggers[0].parameter1: was cty.StringVal(""), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to bunnynet_pullzone_edgerule.block_paths["efg"], provider "provider[\"registry.terraform.io/bunnyway/bunnynet\"]" produced an unexpected new value: .triggers[0].parameter2: was cty.StringVal(""), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

No matter if I set up parameter1 = null or parameter1 = "" the issue is the same

rafael-at-bunny commented 2 months ago

Hi!

Currently it's not possible to unset/remove the value from custom_404_file_path, as this is a limitation in our API. I've flagged the issue to our API team and will update the provider once it's implemented. As a workaround, you can set the value to a path that doesn't exist in your storage, it should then render the original 404 page from Bunny.

Thank you.

rafael-at-bunny commented 1 month ago

Hi.

Our API team fixed the underlying issue and custom_404_file_path can now be unset. Please upgrade the provider to v0.3.12 (just released).

Thank you.

pwilczynskiclearcode commented 1 month ago

@rafael-at-bunny Thank you.

What about .triggers[0].parameter1 and .triggers[0].parameter2 of the edge rules that I mentioned. Why they are always required fields when in many edge rules they must be null. What is this error message about? Is it possible that provider sends "" (empty string) but API returns null so terraform complains?

rafael-at-bunny commented 1 month ago

Hi.

Why they are always required fields when in many edge rules they must be null

That's unfortunately a limitation in the terraform framework (see https://github.com/hashicorp/terraform-plugin-framework/issues/726), as we can't define defaults (or even Required: false) on nested attributes.

What is https://github.com/BunnyWay/terraform-provider-bunnynet/issues/8#issuecomment-2328450959 about?

I'd need more details (as in: the terraform resource that caused it). We are handling empty strings for those attributes, so I'm not sure how you're triggering this error.

https://github.com/BunnyWay/terraform-provider-bunnynet/blob/90ba83d93fc02e6a31d98bccf80054516ee63c61/internal/provider/resource_pullzone_edgerule.go#L405-L410

Thank you.

pwilczynskiclearcode commented 1 month ago

Sorry I can't reproduce it. I believe that was related somehow to using terraform import bunnynet_pullzone_edgerule... but it works now. Thank you for the help