Terraform ERROR:属性"requires_compatibilities""



我得到以下错误信息:

###############################################################

错误:错误的属性值类型.terraform/模块/backend_deployment/task_definition。在第4行,在资源"aws_ecs_task_definition":

requires_compatibility = "FARGATE">

属性"requires_compatibilities"值不合适:需要的字符串集。

###############################################################

这是我的task_definition:
resource "aws_ecs_task_definition" "task_definition" {
family = join("-", [local.cluster_values.backend_name, local.cluster_values.environment, local.cluster_values.random_id])
network_mode = "awsvpc"
requires_compatibilities = "FARGATE"
cpu = 256
memory = 512
container_definitions = data.template_file.task_definition_template.rendered
task_role_arn = local.cluster_values.task_role
}

Terraform-Doku说:

requires_compatible -(可选)任务所需的启动类型集合。有效值为EC2和FARGATE。

谢谢你的帮助!

根据错误消息,提供者正在等待类型为set(string)的参数值,而您已经提供了string。您可以通过提供与提供者根据错误消息所期望的类型一致的值来修复此问题:

requires_compatibilities = ["FARGATE"]

不适合我

// Apply the firewall rule to allow external IPs to access this instance
tags = element(var.instance_tag, count.index)
}
variable "instance_tag" {
type = list
default = ["http-one", "http-two"]
}

添加后可正常工作[]

// Apply the firewall rule to allow external IPs to access this instance
tags = [element(var.instance_tag, count.index)]
}
variable "instance_tag" {
type = list
default = ["http-one", "http-two"]
}

还有另一种方法可以使它与type = list(string)一起工作

// Apply the firewall rule to allow external IPs to access this instance
tags = element(var.instance_tag, count.index)
}
variable "instance_tag" {
type = list(string)
default = ["http-one", "http-two"]
}

最新更新