dnsimple / terraform-provider-dnsimple

Terraform DNSimple provider.
https://www.terraform.io/docs/providers/dnsimple/
Mozilla Public License 2.0
22 stars 20 forks source link

Wildcard DNS record #25

Closed george-oakling closed 1 year ago

george-oakling commented 4 years ago

Terraform Version

0.12.10

Affected Resource(s)

Terraform Configuration Files

resource "dnsimple_record" "redirect_0_wildcard" {
  domain = "*.xxx.com"
  name = ""
  type = "A"
  value = "1.1.1.1"
  ttl = 600
}

Debug Output

Failed to create DNSimple Record: POST https://api.dnsimple.com/v2/XXXX/zones/*.domain.com/records: 404 Zone *.domain.com not foun

Expected Behavior

The wildcard should be placed.

Actual Behavior

404 - zone not found

Steps to Reproduce

  1. terraform apply
boomshadow commented 4 years ago

@george-oakling You get a 404 "not found" because the domain you enter directly correlates to an API URL in DNSimple's system. So by putting ".xxx.com", the API call looks like this:
`https://api.dnsimple.com/v2/REDACTED/zones/
.xxx.com/records`

You can see from your browser in DNSimple's web UI that your domain doesn't exist on that URL. It actually exists on:
https://dnsimple.com/a/REDACTED/domains/xxx.com/records

Long story short, you need the following code:

resource "dnsimple_record" "redirect_0_wildcard" {
  domain = "xxx.com"
  name = "*"
  type = "A"
  value = "1.1.1.1"
  ttl = 600
}

That being said..... I actually can't get that to successfully work for me either. The API rejects it with 400 Validation failed. Yet I can find proof of this method supposedly working for this guy: https://gitlab.oye.io/rauno/mantl/blob/855504c71c02210a42cb9fe1c9b95f32ec524f1a/terraform/dnsimple/dns/main.tf#L51-58

For now, I'm having to resort to making my wildcard entries manually 😢

weppos commented 4 years ago

That being said..... I actually can't get that to successfully work for me either. The API rejects it with 400 Validation failed. Yet I can find proof of this method supposedly working for this guy: https://gitlab.oye.io/rauno/mantl/blob/855504c71c02210a42cb9fe1c9b95f32ec524f1a/terraform/dnsimple/dns/main.tf#L51-58

This response should contain an error payload in the JSON with the individual validation errors. Any chance you can inspect the response and post it here? I'll be happy to take a look.

boomshadow commented 4 years ago

@weppos My apologies. I see my mistake. I was attempting to create a wildcard record that already existed. I needed to import first. I'm used to Route53 errors that tell me when I'm being dumb, creating records that already exist. I was confused by DNSimple's response. All good now!

weppos commented 4 years ago

@weppos My apologies. I see my mistake. I was attempting to create a wildcard record that already existed. I needed to import first. I'm used to Route53 errors that tell me when I'm being dumb, creating records that already exist. I was confused by DNSimple's response. All good now!

Thanks for the feedback. FYI we actually return more detailed errors, but we currently don't expose them https://github.com/dnsimple/dnsimple-go/issues/60

nestorsalceda commented 2 years ago

Hey @george-oakling I would like to communicate that we just released a new version of the provider (0.14.0) that handles these issues.

Thank you for your patience!

george-oakling commented 2 years ago

Wow, thanks a lot! Much appreciated!

weppos commented 1 year ago

Closing as per latest updates.

adiii717 commented 1 year ago

I am trying to create multiple AWS certificates, but when I tried to create zone records it ended up with

│ A matching record already exists for this zone, Another record already exists
│ for _12ee1d57338f45a0e6ef43cxxx.example.com, cannot add a CNAME, A
│ CNAME record exists for _12ee1d57338f45a0e6ef43xxx.example.com,
│ cannot add another record

Any way to perform the update in place?

resource "dnsimple_zone_record" "dnsrecord" {
   for_each = {
    for dvo in aws_acm_certificate.certificate.domain_validation_options : dvo.domain_name => {
      record_name   = dvo.resource_record_name
      record_value = dvo.resource_record_value
      type   = dvo.resource_record_type
      domain_name = dvo.domain_name
    }
  }
  zone_name = var.dnsimple_domain
  name   = each.value.record_name
  value  = each.value.record_value
  type   = each.value.type
  ttl    = 3600
}

resource "aws_acm_certificate" "certificate" {
  domain_name               = var.domain_name
  validation_method         = "DNS"
  subject_alternative_names = var.hosts
  tags = {
    Environment = var.environment
    Terraform   = "true"
  }
}