IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
339 stars 663 forks source link

Cannot create a DNS record containing only '@' as the name field #1838

Closed andrewferrier closed 3 years ago

andrewferrier commented 4 years ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Used through IBM Schematics (Terraform 0.12.20 at the time of writing)

Affected Resource(s)

ibm_cis_dns_record

Terraform Configuration Files

Relevant snippet:

resource "ibm_cis" "cis_instance" {
  name              = "Cloud Internet Services - example.com"
  plan              = "enterprise-usage"
  resource_group_id = data.ibm_resource_group.resource_group.id
  location          = "global"
}

resource "ibm_cis_domain" "examplecom" {
  domain = "example.com"
  cis_id = ibm_cis.cis_instance.id
}

resource "ibm_cis_dns_record" "examplednsa" {
  cis_id    = ibm_cis.cis_instance.id
  domain_id = ibm_cis_domain.examplecom.id
  name      = "@"
  content   = "1.2.3.4"
  type      = "A"
}

Debug Output

Relevant output from Schematics:

2020/08/26 12:24:44 Terraform apply | 
 2020/08/26 12:24:44 Terraform apply | Error: Failed to create record: Request failed with status code: 400, ServerErrorResponse: {"trace": "140c6fe3-c06d-40bc-bb00-52745072b8c5", "errors": [{"code": "CIS-FRT-00005", "message": "property 'name' is a required property"}], "notices": "Scheduled maintenance: September 9, 2020 from 18:00 to 20:00 UTC (9/9/2020 1pm - 3pm US CDT): During this maintenance window, our partner, Cloudflare, will conduct a failover of their control plane services to their secondary site in Luxembourg. The control path might be degraded or unavailable. The data path is not impacted. A second maintenance window is planned for September 16, 2020, for another failover from their secondary site back to their primary site."}
 2020/08/26 12:24:44 Terraform apply | 
 2020/08/26 12:24:44 Terraform apply |   on main.tf line 56, in resource "ibm_cis_dns_record" "examplednsa2":
 2020/08/26 12:24:44 Terraform apply |   56: resource "ibm_cis_dns_record" "examplednsa2" {
 2020/08/26 12:24:44 Terraform apply | 
 2020/08/26 12:24:44 Terraform apply | 
 2020/08/26 12:24:44 Terraform APPLY error: Terraform APPLY errorexit status 1
 2020/08/26 12:24:44 Could not execute action

Expected Behavior

DNS record should be created.

Actual Behavior

DNS record not created, with error "message": "property 'name' is a required property"}.

Steps to Reproduce

  1. Create a Terraform script similar to above.
  2. Wrap in a Schematics workspace.
  3. Run.

Important Factoids

At a guess, I would assume this is some escaping issue or similar with the special char @. However, this is a very common entry to insert in a DNS record, and works fine when manually added to the CIS service.

pauljegouic commented 4 years ago

Hello @andrewferrier, to workaround regarding your need:

resource "ibm_cis" "cis_instance" {
  name              = "Cloud Internet Services - example.com"
  plan              = "enterprise-usage"
  resource_group_id = data.ibm_resource_group.resource_group.id
  location          = "global"
}

resource "ibm_cis_domain" "examplecom" {
  domain = "example.com"
  cis_id = ibm_cis.cis_instance.id
}

resource "ibm_cis_dns_record" "examplednsa" {
  cis_id    = ibm_cis.cis_instance.id
  domain_id = ibm_cis_domain.examplecom.id
  name      =  "example.com"
  content   = "1.2.3.4"
  type      = "A"
}

If you use the same name for your CIS domain, and the ibm_cis_dns_record.name, then it will result in a @ in the CIS records.

andrewferrier commented 4 years ago

Thanks, @ifs-pauljegouic . I was talking to Rolf Kocheisen from CIS and he gave me the same hint. Seems that workaround does work.

kavya498 commented 4 years ago

Hi @andrewferrier, Please let us know if you are able to create dns record with name = "@" with the latest released version of schematics.

hkantare commented 3 years ago

closing the issue