'Terraform ERROR: Inappropriate value for attribute "requires_compatibilities": set of string required
i get the following error message after terraform validate:
###############################################################
Error: Incorrect attribute value type on .terraform/modules/backend_deployment/task_definition.tf line 4, in resource "aws_ecs_task_definition":
requires_compatibilities = "FARGATE"
Inappropriate value for attribute "requires_compatibilities": set of string required.
###############################################################
This is my 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 says this:
requires_compatibilities - (Optional) Set of launch types required by the task. The valid values are EC2 and FARGATE.
Many thanks for helping !
Solution 1:[1]
According to the error message, the provider is expecting an argument value of type set(string)
, and you have provided string
. You can fix this by providing a value consistent with the type expected by the provider according to the error message:
requires_compatibilities = ["FARGATE"]
Solution 2:[2]
Did not work for me
// 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"]
}
Worked when added []
// 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"]
}
There is another way to make it work as well with 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"]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt Schuchard |
Solution 2 |