Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of ECS service failed with enabled service discovery #175

Open
Wishpering opened this issue Oct 3, 2022 · 0 comments
Open

Creation of ECS service failed with enabled service discovery #175

Wishpering opened this issue Oct 3, 2022 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@Wishpering
Copy link

Wishpering commented Oct 3, 2022

Describe the Bug

Can't deploy ECS service with enabled service discovery

Expected Behavior

ECS service with enabled service discovery

Steps to Reproduce

Module are used in this way (ECS + ALB + EFS + Service Discovery)

module "service" {
  source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=0.64.1"

  name                      = var.name
  environment               = var.environment
  container_definition_json = local.containers
  desired_count             = var.desired_count
  ecs_cluster_arn           = var.ecs_cluster_arn
  efs_volumes               = local.jenkins_volume
  ecs_load_balancers = [
    {
      container_name   = var.name
      container_port   = var.container_port
      elb_name         = ""
      target_group_arn = aws_lb_target_group.this.arn
    }
  ]
  launch_type                    = "EC2"
  network_mode                   = "bridge"
  subnet_ids                     = var.subnet_ids
  tags                           = var.common_tags
  task_cpu                       = null
  task_memory                    = null
  vpc_id                         = var.vpc_id
  ignore_changes_task_definition = false
  use_old_arn                    = false
  propagate_tags                 = "TASK_DEFINITION"
  service_registries              = [{
      registry_arn = aws_service_discovery_service.this.arn
      port         = 8080
      container_name = var.name
      container_port = 8080
    }]
}

Now ECS service won't deploy cause of this error:

module.service.aws_ecs_service.default[0]: Creating...
Error: failed creating ECS service (jenkins): InvalidParameterException: You cannot specify an IAM role for services that require a service linked role.
  on .terraform/modules/service/[main.tf](http://main.tf/) line 631, in resource "aws_ecs_service" "default":
 631: resource "aws_ecs_service" "default" {
Releasing state lock. This may take a few moments...
[terragrunt] 2022/09/30 10:54:48 Hit multiple errors:
exit status 1

When I am deleting service_registries, everything works fine.
Also switching network_mode to AWSVPC solves this problem too (due to lack of need for IAM policy in this case)

Environment:

  • Terraform = 0.14.11
  • Terragrunt = 0.25.3
  • AWS Provider = 3.75.2
@Wishpering Wishpering added the bug 🐛 An issue with the system label Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant