等待 ECS 集群的 Terraform 错误
Terraform erroring waiting for ECS cluster
我正在使用 Terraform 在 AWS 中创建 ECS 集群。
resource "aws_ecs_cluster" "cluster" {
name = "api-cluster"
capacity_providers = ["FARGATE"]
default_capacity_provider_strategy {
capacity_provider = "FARGATE"
weight = "100"
}
}
每当我 运行 这段代码开始时它运行良好,但是在等待创建集群时出现错误。
Terraform v1.0.0
on linux_amd64
Initializing plugins and modules...
aws_ecs_cluster.cluster: Creating...
aws_ecs_cluster.cluster: Still creating... [10s elapsed]
╷
│ Error: error waiting for ECS Cluster (arn:aws:ecs:xxxxxxxxxxx:cluster/api-cluster) to become Available: couldn't find resource
│
│ with aws_ecs_cluster.cluster,
│ on main.tf line 73, in resource "aws_ecs_cluster" "cluster":
│ 73: resource "aws_ecs_cluster" "cluster" {
│
╵
最终部署了ECS集群,但是脚本出错。我做错了什么?
事实证明,这是因为需要允许用户执行 terraform apply
操作 ecs:DescribeClusters
。
感谢 @ydaetskocR 为我指明了正确的方向。
就我而言,我有:
resource "aws_ecs_cluster" "cluster" {
name = "${var.service}-${var.env}"
}
module "ecs_service" {
source = "app.terraform.io/ifit/ecs-service/aws"
version = "2.3.0"
cluster_name = aws_ecs_cluster.cluster.name
...other stuff...
}
它试图同时创建 ecs 集群和 ecs 服务,但该服务依赖于 cluster_name
的集群。我需要将 depends_on
属性添加到 ecs_service
:
module "ecs_service" {
source = "app.terraform.io/ifit/ecs-service/aws"
version = "2.3.0"
cluster_name = aws_ecs_cluster.cluster.name
...other stuff...
depends_on = [
aws_ecs_cluster.cluster
]
}
我正在使用 Terraform 在 AWS 中创建 ECS 集群。
resource "aws_ecs_cluster" "cluster" {
name = "api-cluster"
capacity_providers = ["FARGATE"]
default_capacity_provider_strategy {
capacity_provider = "FARGATE"
weight = "100"
}
}
每当我 运行 这段代码开始时它运行良好,但是在等待创建集群时出现错误。
Terraform v1.0.0
on linux_amd64
Initializing plugins and modules...
aws_ecs_cluster.cluster: Creating...
aws_ecs_cluster.cluster: Still creating... [10s elapsed]
╷
│ Error: error waiting for ECS Cluster (arn:aws:ecs:xxxxxxxxxxx:cluster/api-cluster) to become Available: couldn't find resource
│
│ with aws_ecs_cluster.cluster,
│ on main.tf line 73, in resource "aws_ecs_cluster" "cluster":
│ 73: resource "aws_ecs_cluster" "cluster" {
│
╵
最终部署了ECS集群,但是脚本出错。我做错了什么?
事实证明,这是因为需要允许用户执行 terraform apply
操作 ecs:DescribeClusters
。
感谢 @ydaetskocR 为我指明了正确的方向。
就我而言,我有:
resource "aws_ecs_cluster" "cluster" {
name = "${var.service}-${var.env}"
}
module "ecs_service" {
source = "app.terraform.io/ifit/ecs-service/aws"
version = "2.3.0"
cluster_name = aws_ecs_cluster.cluster.name
...other stuff...
}
它试图同时创建 ecs 集群和 ecs 服务,但该服务依赖于 cluster_name
的集群。我需要将 depends_on
属性添加到 ecs_service
:
module "ecs_service" {
source = "app.terraform.io/ifit/ecs-service/aws"
version = "2.3.0"
cluster_name = aws_ecs_cluster.cluster.name
...other stuff...
depends_on = [
aws_ecs_cluster.cluster
]
}