Terraform Fargate ECS提供无效或未知密钥:require_compatibilities

时间:2018-07-05 23:05:28

标签: amazon-web-services terraform terraform-provider-aws aws-fargate

我在Terraform脚本上运行Terraform计划以启用Fargate,但出现以下错误:

  

错误:aws_ecs_task_definition.task:无效或未知密钥:   require_compatibilities

  

错误:aws_ecs_service.service ::无效或未知密钥:launch_type

不确定为什么Terraform不接受用于启用Fargate的键launch_typerequires_compatibilities

以下是我的任务和Terraform的ECS服务设置:

Terraform

resource "aws_ecs_task_definition" "task" {
  family                   = "${var.name_prefix}_gateway"
  container_definitions    = "${template_file.task.rendered}"
  requires_compatibilities = ["FARGATE"]
  network_mode             = "bridge"

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_ecs_service" "service" {
  name                               = "${var.name_prefix}_service"
  launch_type                        = "FARGATE"
  cluster                            = "${aws_ecs_cluster.terraform_cluster.id}"
  task_definition                    = "${aws_ecs_task_definition.task.arn}"
  desired_count                      = "${var.desired_count}"
  deployment_minimum_healthy_percent = 50
  deployment_maximum_percent         = 200
  iam_role                           = "${var.ecs_service_role}"

  load_balancer {
    target_group_arn = "${aws_alb_target_group.svc.arn}"
    container_name   = "task"
    container_port   = 8000
  }

  lifecycle {
    create_before_destroy = true
  }
}

1 个答案:

答案 0 :(得分:1)

requires_compatibilitieslaunch_typev1.6.0 of the AWS provider中引入。

将您的提供程序更新为1.6.0或更高版本,就可以了。

请注意,v0.1.4于2017年8月问世,随后v1.0.0于2017年9月27日发布,这远远早于Fargate宣布。