Terraform修改现有Route53记录,而不是插入新记录
我在这里有一个区域:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我添加的TXT记录是Route53中的现有记录。我的
Terraform Import
命令不正确,导致Terraform改为修改example.com
记录。更改:
到:
Terraform计划现在按预期运行。
The TXT record I was adding was an existing record in Route53. My
terraform import
command was incorrect, causing terraform to modify theexample.com
record instead.Changed:
To:
terraform plan now works as expected.