使用Terraform时,使用configuration的IAM策略时,ecs服务创build失败。
Error applying plan: 1 error(s) occurred: * aws_ecs_service.beatthemarket_service: InvalidParameterException: Unable to assume role and validate the listeners configured on your load balancer. Please verify the role being passed has the proper permissions. status code: 400, request id: ba3a3fb8-0972-11e6-a877-954fd57ba1a9
这似乎与这个问题一致 。 但是我似乎无法修复它,即使在添加策略之后 。 我也不认为这是一个计时问题,因为angular色已经存在,经过多次terraform apply 。
到目前为止,我只有一个IAM angular色 , 策略 , ELB和ECS 集群 , 服务和任务定义 。 我是否需要其他任何东西,比如Autoscaling组 , 启动configuration , 实例configuration文件或安全组 ?
有什么明显的缺失,这解释了为什么服务不能接受我configuration的angular色? angular色似乎拥有所有正确的权限。
resource "aws_iam_role_policy" "beatthemarket" { name = "beatthemarket" role = "${aws_iam_role.beatthemarket.id}" policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Action": [ "ec2:*", "ecs:*", "iam:*", "elasticloadbalancing:*" ], "Effect": "Allow", "Resource": "*" } ] } EOF }
原来我需要设置服务ecs.amazonaws.com而不是ec2.amazonaws.com在我的aws_iam_role 。 我曾尝试过,但没有在aws_iam_role_policy中指定足够的。 这在AWS论坛上非常像这个问题 。
resource "aws_iam_role" "beatthemarket" { name = "beatthemarket" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Principal": { "Service": "ecs.amazonaws.com" }, "Effect": "Allow", "Sid": "" } ] } EOF }
为了将来的参考,希望这有助于某人。