Terraform修改现有Route53记录,而不是插入新记录

发布于 2025-02-13 21:35:03 字数 2539 浏览 0 评论 0原文

我在这里有一个区域:

resource "aws_route53_zone" "example_com" {
  name = "example.com"
}

现有的TXT记录:

resource "aws_route53_record" "example_com_txt" {
  zone_id = aws_route53_zone.example_com.zone_id
  name    = "example.com"
  type    = "TXT"
  ttl     = "300"
  records = [
    "v=spf1 foo ~all",
    "google-site-verification=zzzz",
    "google-site-verification=bbbb",
    "other-things",
    "MS=ms12345",
    "apple-domain-verification=abcd12345"
  ]
}

尝试添加此TXT记录:

resource "aws_route53_record" "easydmarc_txt" {
  zone_id = aws_route53_zone.example_com.zone_id
  name.   = "_dmarc.example.com"
  type    = "TXT"
  ttl     = "300"
  records = ["v=DMARC1; p=quarantine; rua=mailto:[email protected], mailto:[email protected]; ruf=mailto:[email protected]; fo=1"]
}

当我尝试运行Terraform Plan -target Module.Route53.AWS_ROUTE53_RECORD.EASYDMARC_TXT时,它似乎正在尝试修改它现有的TXT记录:

  # module.route53.aws_route53_record.easydmarc_txt must be replaced
-/+ resource "aws_route53_record" "easydmarc_txt" {
      + allow_overwrite = (known after apply)
      ~ fqdn            = "example.com" -> (known after apply)
      ~ id              = "Z0N3ID_example.com_TXT" -> (known after apply)
      ~ name            = "example.com" -> "_dmarc" # forces replacement
      ~ records         = [
          - "MS=MS=ms12345",
          - "apple-domain-verification=abcd12345",
          - "google-site-verification=zzzz",
          - "google-site-verification=bbbb",
          - "other-things",
          + ""v=DMARC1; p=quarantine; rua=mailto:somename.somedomain.us, mailto:[email protected]; ruf=mailto:[email protected]; fo=1",
          - "v=spf1 foo ~all",
        ]
        # (3 unchanged attributes hidden)
    }

我不明白为什么它试图修改现有记录。

I have a zone here:

resource "aws_route53_zone" "example_com" {
  name = "example.com"
}

An existing TXT record here:

resource "aws_route53_record" "example_com_txt" {
  zone_id = aws_route53_zone.example_com.zone_id
  name    = "example.com"
  type    = "TXT"
  ttl     = "300"
  records = [
    "v=spf1 foo ~all",
    "google-site-verification=zzzz",
    "google-site-verification=bbbb",
    "other-things",
    "MS=ms12345",
    "apple-domain-verification=abcd12345"
  ]
}

Trying to add this TXT record:

resource "aws_route53_record" "easydmarc_txt" {
  zone_id = aws_route53_zone.example_com.zone_id
  name.   = "_dmarc.example.com"
  type    = "TXT"
  ttl     = "300"
  records = ["v=DMARC1; p=quarantine; rua=mailto:[email protected], mailto:[email protected]; ruf=mailto:[email protected]; fo=1"]
}

When I attempt to run terraform plan -target module.route53.aws_route53_record.easydmarc_txt, it appears to be attempting to modify the existing TXT record:

  # module.route53.aws_route53_record.easydmarc_txt must be replaced
-/+ resource "aws_route53_record" "easydmarc_txt" {
      + allow_overwrite = (known after apply)
      ~ fqdn            = "example.com" -> (known after apply)
      ~ id              = "Z0N3ID_example.com_TXT" -> (known after apply)
      ~ name            = "example.com" -> "_dmarc" # forces replacement
      ~ records         = [
          - "MS=MS=ms12345",
          - "apple-domain-verification=abcd12345",
          - "google-site-verification=zzzz",
          - "google-site-verification=bbbb",
          - "other-things",
          + ""v=DMARC1; p=quarantine; rua=mailto:somename.somedomain.us, mailto:[email protected]; ruf=mailto:[email protected]; fo=1",
          - "v=spf1 foo ~all",
        ]
        # (3 unchanged attributes hidden)
    }

I'm not understanding why it's trying to modify the existing record.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2025-02-20 21:35:03

我添加的TXT记录是Route53中的现有记录。我的Terraform Import命令不正确,导致Terraform改为修改example.com记录。

更改:

terraform import module.route53.aws_route53_record.easydmarc_txt Z0N3ID_example.com_TXT

到:

terraform import module.route53.aws_route53_record.easydmarc_txt Z0N3ID__dmarc.example.com_TXT

Terraform计划现在按预期运行。

The TXT record I was adding was an existing record in Route53. My terraform import command was incorrect, causing terraform to modify the example.com record instead.

Changed:

terraform import module.route53.aws_route53_record.easydmarc_txt Z0N3ID_example.com_TXT

To:

terraform import module.route53.aws_route53_record.easydmarc_txt Z0N3ID__dmarc.example.com_TXT

terraform plan now works as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文