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

BUG (dns zone, dns recordset): Provider produced inconsistent result after apply #110

Open
matsui-p opened this issue Aug 15, 2023 · 0 comments

Comments

@matsui-p
Copy link

matsui-p commented Aug 15, 2023

Terraform Version

1.5.5

Affected Resource(s)

ecl_dns_recordset_v2
ecl_dns_zone_v2

Terraform Configuration Files

main.tf 
module "ecl_dns" {
  source      = "./ecl_dns"
  record = var.record
  zone   = var.zone
}

providers.tf 
terraform {	
  required_providers {
    ecl = {
      source  = "nttcom/ecl"
      version = "2.5.2" 
    }
  }
  required_version = "1.5.5"
}

variables.tf 
variable "zone" {
  type        = list(string)
}

variable "record" {
  type = map(object({
    zone    = string
    name    = string
    ttl     = optional(number, 300)
    type    = string
    records = list(string)
  }))
}

terraform.tfvars 
zone = ["guuguru.com"]
record = {
  azul = {
    zone    = "guuguru.com"
    name    = "azul.guuguru.com."
    type    = "NS"
    ttl     = 60
    records = ["ns1.azul-dns.com.", "ns2.azul-dns.net.", "ns3.azul-dns.org.", "ns4.azul-dns.info."]
  },
  sso = {
    zone    = "guuguru.com"
    name    = "sso.guuguru.com."
    type    = "A"
    records = ["1.1.1.1"]
  },
  lb = {
    zone    = "guuguru.com"
    name    = "lb.guuguru.com."
    type    = "A"
    records     = ["2.2.2.2", "3.3.3.3", "4.4.4.4"]
  },
  wild = {
    zone    = "guuguru.com"
    name        = "*.guuguru.com."
    ttl     = 900
    type    = "A"
    records     = ["5.5.5.5"]
  },
  ses = {
    zone    = "guuguru.com"
    name        = "abc._d.guuguru.com."
    type        = "CNAME"
    records     = ["abc.dkim.amazonses.com"]
  },
  verify = {
    zone    = "guuguru.com"
    name        = "_ases.guuguru.com."
    type        = "TXT"
    records     = ["\"123ASD\""]
  }
}

ecl_dns/main.tf 
resource "ecl_dns_zone_v2" "zone" {
  for_each = toset(var.zone)
  name     = "${each.value}."
}

resource "ecl_dns_recordset_v2" "recordset" {
  for_each = merge(local.record_local...)
  zone_id  = ecl_dns_zone_v2.zone[each.value.zone].id
  name     = each.value.name
  type     = each.value.type
  ttl      = each.value.ttl
  record   = each.value.record
}

locals {
  record_local = flatten([ 
    for key, record in var.record : [
      for i, r in record.records : {
        "${key}_${i + 1}" = {
          "zone"   = record.zone
          "name"   = record.name
          "type"   = record.type
          "ttl"    = record.ttl
          "record" = r
        }
      }
    ]
  ]
 )
}

ecl_dns/providers.tf 
terraform {
  required_providers {
    ecl = {
      source  = "nttcom/ecl"
      version = "2.5.2"
    }
  }
  required_version = "1.5.5"
}

ecl_dns/variables.tf 
variable "zone" {
  type        = list(string)
}

variable "record" {
  type = map(object({
    zone    = string
    name    = string
    ttl     = optional(number, 300) 
    type    = string
    records = list(string)
  }))
}

Debug Output

https://gist.github.com/matsui-p/bf5868eab8c4be67043822e1dc1f1e9d
(一部情報をマスク・省略)

Panic Output

該当なし

Expected Behavior

  • aplyした結果、tfコードで定義されている全てのレコード作成が正常に完了(ecl上の作成だけに限らず、tfstateへの正常反映をふくむ)

Actual Behavior

  • aply時にterraformからプロバイダのバグ報告が出力 (デバッグ結果を参照)
    *aplyした結果、 リソースはecl上で作成されるが、tfstateに正しく反映されない
    • 再実行の場合、tfがもう一度、リソースを作成しようとしているが、すでに作成済のため、競合でエラー出力中
    • 削除ー>再作成 (terraform destroy -> terraform apply)で、本報告の事象が解消せずに再現

Steps to Reproduce

terraform init
terraform apply -auto-approve

Important Factoids

該当なし

References

該当なし

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

1 participant