DEV Community

ahn4
ahn4

Posted on

[ECS] Service launch Error - "the role being passed has the proper trust relationship and permissions"?

Error

I got the following error when applied terraform.

service xxxxx failed to launch a task with (error ECS was unable to assume the role 'xxxxx' that was provided for this task. Please verify that the role being passed has the proper trust relationship and permissions and that your IAM user has permissions to pass this role.).
Enter fullscreen mode Exit fullscreen mode

How to fix

Added the assign_public_ip in terraform

resource "aws_ecs_service" "ecs" {
  name = var.ecs_service_name
  cluster = var.ecs_cluster_name
  launch_type = "FARGATE"
  desired_count = "1"
  task_definition = xxxxx

  network_configuration {
    subnets         = [xxxxx]
    security_groups = [xxxxx]

    # NEW
    assign_public_ip = true
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)