创建ECS与DNS服务错误使用起程拓殖SRV记录



我需要在AWS ECS中为每个正在运行的容器/任务创建DNS条目,因此我认为SRV记录可以工作。然而,Terraform (1.2.4 with provider hashicorp/aws v4.22.0)错误:

│错误:创建ECS服务失败(ECS -service-xxx): InvalidParameterException:当为serviceregistres指定一个值时,该值被配置为使用"SRV"类型的DNS记录,您还必须为"port"或"containerName"one_answers"containerPort"组合输入一个值,但不能同时输入两个值。注册中心:在攻击:aws: servicediscovery: us-west-1: nnnnnnnnn:服务/srv-xxxxxxxxxxx

这是我的代码:

resource "aws_service_discovery_service" "service-discovery-service" {
name = "service-discovery-service-${var.environmentName}"
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.service-discovery-private-dns-namespace.id
dns_records {
ttl  = 10
type = "SRV"
}
routing_policy = "MULTIVALUE"
}
health_check_custom_config {
failure_threshold = 1
}
}

这是Terraform文档:https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/service_discovery_service dns_records

我试着把containerName和containerPort字段放在dns_records中,但这些参数似乎不支持。

任何想法?

您必须在aws_ecs_service资源的service_registrations部分指定这些设置。

最新更新