【发布时间】:2022-01-04 15:22:16
【问题描述】:
我正在尝试使用 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/bash\necho 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 会返回此错误。
我们将不胜感激。
提前致谢。
【问题讨论】:
标签: amazon-web-services terraform amazon-ecs