我在 AWS 中启动并运行了一个完全可用的 Fargate 应用程序。我回去为我的所有资源添加标签,以更好地监控微服务架构中的成本。向我的 aws_ecs_service 资源添加标签后,运行时出现以下异常terraform apply:
aws_ecs_service.main: error tagging ECS Cluster (arn:aws:ecs:*region*:*account_number*:service/*service_name*): InvalidParameterException: Long arn format must be used for tagging operations
Run Code Online (Sandbox Code Playgroud)
经过一番研究,发现11月15日AWS引入了新的ARN和ID格式:https : //aws.amazon.com/ecs/faqs/#Transition_to_new_ARN_and_ID_format
我知道我需要将设置应用到我分配给我的服务的 IAM 角色,但我不知道如何。以下是账户设置的 AWS 文档链接:https : //docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Setting.html
以下是 ecs 服务资源以及任务定义的片段:
resource "aws_ecs_task_definition" "app" {
family = "${var.app_name}"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "${var.app_cpu}"
memory = "${var.app_memory}"
execution_role_arn = "${var.execution_role_arn}"
task_role_arn = "${var.task_role_arn}"
tags {
Name = "${var.app_name}-ecs-task-definition-${var.environment}"
Service = "${var.app_name}"
Environment = "${var.environment}"
Cost_Center = "${var.tag_cost_center}" …Run Code Online (Sandbox Code Playgroud)