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

ERROR: You need to pass an ID. #4

Open
mgvalverde opened this issue Oct 18, 2024 · 3 comments
Open

ERROR: You need to pass an ID. #4

mgvalverde opened this issue Oct 18, 2024 · 3 comments

Comments

@mgvalverde
Copy link

Hi,

This issue is related to #2 , but it occurs when updating a porkbun_dns_record.

Having a resource defined like this:

resource "porkbun_dns_record" "ns" {

  domain   = var.domain
  name     = var.name
  type     = "NS"
  content  = var.ns_value
  ttl      = var.ttl
  priority = var.priority
  notes    = var.notes
}

The first time you apply, it works. Destroy, works as well. But if you decide to change any parameter and apply again, it fails:

╷
│ Error: Unable to update DNS record
│ 
│   with module.subdomains.porkbun_dns_record.ns,
│   on ../../modules/subdomain/main.tf line 10, in resource "porkbun_dns_record" "ns":
│   10: resource "porkbun_dns_record" "ns" {
│ 
│ ERROR: You need to pass an ID.
╵

It is possible to bypass this exception adding a lifecycle forcing to always destroy and create the records, like:

resource "null_resource" "always_run" {
  triggers = {
    timestamp = "${timestamp()}"
  }
}

resource "porkbun_dns_record" "ns" {
  domain   = var.domain
  name     = var.name
  type     = "NS"
  content  = var.ns_value
  ttl      = var.ttl
  priority = var.priority
  notes    = var.notes

  lifecycle {
    replace_triggered_by = [
      null_resource.always_run
    ]
  }
}

But I wonder if it wouldn't be better to have a cleaner way to update the parameters.

Best regards

@matthieugouel
Copy link

matthieugouel commented Oct 23, 2024

Hey I have the same issue. I wonder if the porkbun API changed or something because there is the same issue with the other porkbun terraform provider: cullenmcdermott/terraform-provider-porkbun#68

I don't succeed to make your fix work by the way even with the lifecycle I have the ERROR: You need to pass an ID. error.

@kyswtn
Copy link
Owner

kyswtn commented Oct 23, 2024

I wonder if the porkbun changed or something

Likely. I used the provider last week and personally didn't had any problems myself create/destroy. Let me try to reproduce it myself and get back to you both.

@matthieugouel
Copy link

matthieugouel commented Nov 11, 2024

I've looked it up a bit today by playing with logs, and apparently we don't have any ID when we are in Update function (and therefore in the EditDNSRecord function). So we don't put the ID in the Pokbun API URL and Porkbun complains about it.

I don't really understand why because we have the ID for the Delete function, and it is about the same thing.

I use hashicorp/tap/terraform 1.9.8 (latest) by the way.

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

No branches or pull requests

3 participants