DEV Community

ahn4
ahn4

Posted on

1 1

[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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay