Resource: aws_ecs_task_set

Provides an ECS task set - effectively a task that is expected to run until an error occurs or a user terminates it (typically a webserver or a database).

See ECS Task Set section in AWS developer guide.

Example Usage

resource "aws_ecs_task_set" "example" {
  service         = aws_ecs_service.example.id
  cluster         = aws_ecs_cluster.example.id
  task_definition = aws_ecs_task_definition.example.arn

  load_balancer {
    target_group_arn = aws_lb_target_group.example.arn
    container_name   = "mongo"
    container_port   = 8080
  }
}

Ignoring Changes to Scale

You can utilize the generic Terraform resource lifecycle configuration block with ignore_changes to create an ECS service with an initial count of running instances, then ignore any changes to that count caused externally (e.g. Application Autoscaling).

resource "aws_ecs_task_set" "example" {
  # ... other configurations ...

  # Example: Run 50% of the servcie's desired count
  scale {
    value = 50.0
  }

  # Optional: Allow external changes without Terraform plan difference
  lifecycle {
    ignore_changes = ["scale"]
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

capacity_provider_strategy

The capacity_provider_strategy configuration block supports the following:

load_balancer

The load_balancer configuration block supports the following:

network_configuration

The network_configuration configuration block supports the following:

For more information, see Task Networking.

scale

The scale configuration block supports the following:

service_registries

service_registries support the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import ECS Task Sets using the task_set_id, service, and cluster separated by commas (,). For example:

import {
  to = aws_ecs_task_set.example
  id = "ecs-svc/7177320696926227436,arn:aws:ecs:us-west-2:123456789101:service/example/example-1234567890,arn:aws:ecs:us-west-2:123456789101:cluster/example"
}

Using terraform import, import ECS Task Sets using the task_set_id, service, and cluster separated by commas (,). For example:

% terraform import aws_ecs_task_set.example ecs-svc/7177320696926227436,arn:aws:ecs:us-west-2:123456789101:service/example/example-1234567890,arn:aws:ecs:us-west-2:123456789101:cluster/example