cullenmcdermott / terraform-provider-porkbun

Mozilla Public License 2.0
36 stars 8 forks source link

Unable to properly apply repeatedly. #37

Closed pnathan closed 1 year ago

pnathan commented 1 year ago

after applying, TF tries to reapply something to do with the ID

I do an apply, then another apply without any changes....

  # porkbun_dns_record.housecarl-cloud will be updated in-place
  ~ resource "porkbun_dns_record" "housecarl-cloud" {
        id      = "342798344"
        # (5 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
╷
│ Warning: Redundant ignore_changes element
│ 
│   on main.tf line 52, in resource "porkbun_dns_record" "housecarl-cloud":
│   52: resource porkbun_dns_record "housecarl-cloud" {
│ 
│ Adding an attribute name to ignore_changes tells Terraform to ignore future changes to the argument in configuration after the object has been created, retaining the
│ value originally configured.
│ 
│ The attribute id is decided by the provider alone and therefore there can be no configured value to compare with. Including this attribute in ignore_changes has no
│ effect. Remove the attribute from ignore_changes to quiet this warning.
╵

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

porkbun_dns_record.housecarl-cloud: Modifying... [id=342798344]
╷
│ Error: Error updating the record
│ 
│   with porkbun_dns_record.housecarl-cloud,
│   on main.tf line 52, in resource "porkbun_dns_record" "housecarl-cloud":
│   52: resource porkbun_dns_record "housecarl-cloud" {
│ 
│ Error status: 400 message: {"status":"ERROR","message":"Edit error: We were unable to edit the DNS record."}
╵

relevant resource:

resource porkbun_dns_record "housecarl-cloud" {
  domain  = "housecarl.cloud"
  type    = "A"
  ttl = "300"
  content = module.housecarl-site.ip_address
  lifecycle {
    ignore_changes = [id]
  }
}
cullenmcdermott commented 1 year ago

Hi! Can you confirm you're using the latest version of the provider? Also why are you ignoring changes on the Id? Is that an attempt to work around this issue?

This is very similar to a bug I encountered when I was upgrading the plugin framework version and I thought I'd addressed it so if you confirm you're on the latest provider version I'll need to do some digging.

pnathan commented 1 year ago

Yes, I confirm that I'm using the latest version.

And, yes, the lifecyle clause is an attempt to work around the issue.


  porkbun = {      source  = "cullenmcdermott/porkbun"      version =
"0.2.2"    }

Regards, Paul

On Fri, Aug 4, 2023 at 12:00 PM Cullen McDermott @.***> wrote:

Hi! Can you confirm you're using the latest version of the provider? Also why are you ignoring changes on the Id? Is that an attempt to work around this issue?

— Reply to this email directly, view it on GitHub https://github.com/cullenmcdermott/terraform-provider-porkbun/issues/37#issuecomment-1666050091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFZZYFUVSY4FSVQJIOLVQTXTVBD3ANCNFSM6AAAAAA3DU3NBU . You are receiving this because you authored the thread.Message ID: @.*** com>

cullenmcdermott commented 1 year ago

Thanks! I was able to recreate this and it reminded me of a bug that I didn't end up addressing in the latest release.

You should be able to work around this by changing your resource like so:

resource porkbun_dns_record "housecarl-cloud" {
  domain  = "housecarl.cloud"
  type    = "A"
  ttl = "300"
  content = module.housecarl-site.ip_address
  name = ""
}

Setting name = "" makes terraform correctly detect that there are no changes.

Additionally I notice that you set the ttl to 300, according to the api docs the minimum is 600, I don't think this is causing your issue but wanted to mention it since you are likely not getting the result you hope for with that. I created #39 to prevent this in the future.

pnathan commented 1 year ago

Glad to get a reproduction!

The workaround was successful.

Thanks for the headsup about the TTL misconfiguration, I fixed it.

Regards, Paul

On Fri, Aug 4, 2023 at 1:46 PM Cullen McDermott @.***> wrote:

Thanks! I was able to recreate this and it reminded me of a bug https://github.com/cullenmcdermott/terraform-provider-porkbun/blob/main/internal/provider/resource_dns_record.go#L60-L61 that I didn't end up addressing in the latest release.

You should be able to work around this by changing your resource like so:

resource porkbun_dns_record "housecarl-cloud" { domain = "housecarl.cloud" type = "A" ttl = "300" content = module.housecarl-site.ip_address name = "" }

Setting name = "" makes terraform correctly detect that there are no changes.

Additionally I notice that you set the ttl to 300, according to the api docs https://porkbun.com/api/json/v3/documentation#DNS%20Create%20Record the minimum is 600, I don't think this is causing your issue but wanted to mention it since you are likely not getting the result you hope for with that. I created #39 https://github.com/cullenmcdermott/terraform-provider-porkbun/issues/39 to prevent this in the future.

— Reply to this email directly, view it on GitHub https://github.com/cullenmcdermott/terraform-provider-porkbun/issues/37#issuecomment-1666163742, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFZZYDOW25DMMHIAXJI3ADXTVNQZANCNFSM6AAAAAA3DU3NBU . You are receiving this because you authored the thread.Message ID: @.*** com>