aws-ECS容量提供商权限



我正在尝试teraform来管理我的基础设施,遇到了一些问题,我不知道该找什么。

我正在尝试为我的ECS集群创建一个容量提供商,但我得到了以下错误

ClientException: The capacity provider could not be created because you do not have autoscaling:CreateOrUpdateTags permissions to create tags on the Auto Scaling group

以下是我的文件:

启动配置并自动缩放组创建

resource "aws_launch_configuration" "ecs_launch_configuration" {
name = "ecs_launch_configuration"
image_id = "ami-0fe19057e9cb4efd8"
user_data = "#!/bin/bashnecho ECS_CLUSTER=ecs_cluster >> /etc/ecs/ecs.config"
security_groups = [aws_security_group.vpc_securityGroup.id]
iam_instance_profile = aws_iam_instance_profile.iam_role_profile.name
key_name = "key_pair_name"
instance_type = "t2.small"
}
resource "aws_autoscaling_group" "ecs_autoScale_group" {
name                      = "ecs_autoScale_group"
desired_capacity          = 1
min_size                  = 1
max_size                  = 2
launch_configuration = aws_launch_configuration.ecs_launch_configuration.name
vpc_zone_identifier = [aws_subnet.vpc_subnet_public.id]
tag {
key                 = "AmazonECSManaged"
value               = true
propagate_at_launch = true
}
}

ECS集群和容量提供商创建

resource "aws_ecs_cluster" "ecs_cluster"{
name = "ecs_cluster"
capacity_providers = [ aws_ecs_capacity_provider.ecs_capacity_provider.name ]
}
resource "aws_ecs_capacity_provider" "ecs_capacity_provider" {
name = "ecs_capacity_provider"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.ecs_autoScale_group.arn
managed_scaling {
maximum_scaling_step_size = 2
minimum_scaling_step_size = 1
status                    = "ENABLED"
target_capacity           = 1
}
}
}

我可以从控制台的GUI创建这个,但是只有terraform返回这个错误。

我们将不胜感激。

提前谢谢。

(猜测(

不是因为您在Terraform代码中使用的IAM用户缺少autoscaling:CreateOrUpdateTags权限吗?

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-auto-scaling.html说:

创建容量提供程序的IAM用户需要自动缩放:CreateOrUpdateTags权限。这是因为亚马逊云服务器在将自动缩放组与容量提供商关联时,会向其添加一个标签。

最新更新