ish*_*ish 5 amazon-web-services amazon-route53 terraform terraform-provider-aws
由于域已经存在,我将该区域导入到我的配置中:
resource "aws_route53_zone" "example_hosted_zone" {
name = "example.club"
}
Run Code Online (Sandbox Code Playgroud)
53号公路记录:
resource "aws_route53_record" "us-battasks" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasks"
type = "CNAME"
ttl = "60"
records = [aws_lb.restricted_access_lb.id]
}
resource "aws_route53_record" "us-battasksapi" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasksapi"
type = "CNAME"
ttl = "60"
records = [aws_lb.restricted_access_lb.id]
}
Run Code Online (Sandbox Code Playgroud)
Terraform 计划显示它将创建资源,但当我应用时,我收到以下错误:
Error: [ERR]: Error building changeset: InvalidChangeBatch: [Invalid Resource Record: FATAL problem: DomainLabelTooLong (Domain label is too long) encountered with 'arn:aws:elasticloadbalancing:us-east-1:221124075124:loadbalancer', Unparseable CNAME encountered]
status code: 400, request id: e43e5ced-957f-4bcd-83d2-1e7eaea7665b
Error: [ERR]: Error building changeset: InvalidChangeBatch: [Invalid Resource Record: FATAL problem: DomainLabelTooLong (Domain label is too long) encountered with 'arn:aws:elasticloadbalancing:us-east-1:221124075124:loadbalancer', Unparseable CNAME encountered]
status code: 400, request id: 33d3340e-f2f2-4c95-bc96-a9de1349afc4
Run Code Online (Sandbox Code Playgroud)
如果有帮助的话,这是负载均衡器的 Terraform 代码:
resource "aws_lb" "restricted_access_lb" {
name = "restricted-access-lb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.swarm_node_sg.id, aws_security_group.monolaunch_instance_sg.id, aws_security_group.restricted_access_sg.id]
subnets = [aws_subnet.public_subnet_b.id, aws_subnet.public_subnet_a.id]
enable_deletion_protection = true
}
Run Code Online (Sandbox Code Playgroud)
yda*_*coR 10
资源id的ARN 是您在尝试创建 Route53 记录时看到错误中显示的负载均衡器 ARN 的原因aws_lb。
相反,您应该使用该dns_name属性来映射到负载均衡器的地址。
resource "aws_route53_record" "us-battasksapi" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasksapi"
type = "CNAME"
ttl = "60"
records = [aws_lb.restricted_access_lb.dns_name]
}
Run Code Online (Sandbox Code Playgroud)
相反,如果您想使用别名 A 记录来避免第二次 DNS 查找(以及区域中 apex 记录的问题),您可以使用以下命令:
resource "aws_route53_record" "us-battasksapi" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasksapi"
type = "A"
alias {
name = aws_lb.restricted_access_lb.dns_name
zone_id = aws_lb.restricted_access_lb.zone_id
evaluate_target_health = true
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6150 次 |
| 最近记录: |