awscc_ecs_service (Resource)

The AWS::ECS::Service resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers. The stack update fails if you change any properties that require replacement and at least one Amazon ECS Service Connect ServiceConnectService is configured. This is because AWS CloudFormation creates the replacement service first, but each ServiceConnectService must have a name that is unique in the namespace. Starting April 15, 2023, AWS; will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, ECS, or EC2. However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service.

Example Usage

Amazon ECS service on Fargate

data "awscc_ec2_subnet" "subnet" {
  id = "subnet-0000000"
}

resource "awscc_iam_role" "nginx" {
  role_name                   = "ecs_Task_ExecutionRole"
  assume_role_policy_document = <<EOF
{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "sts:AssumeRole",
        "Principal": {
          "Service": "ecs-tasks.amazonaws.com"
        },
        "Effect": "Allow",
        "Sid": ""
      }
    ]
}
  EOF
  managed_policy_arns         = ["arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"]
}

resource "awscc_ecs_service" "nginx" {
  service_name    = "nginx_service"
  cluster         = awscc_ecs_cluster.this.id
  task_definition = aws_ecs_task_definition.nginx.arn
  launch_type     = "FARGATE"
  desired_count   = 1

  network_configuration = {
    awsvpc_configuration = {
      assign_public_ip = "ENABLED"
      subnets          = ["${data.awscc_ec2_subnet.subnet.subnet_id}"]
    }
  }

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
  depends_on = [awscc_iam_role.nginx]
}
{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "sts:AssumeRole",
        "Principal": {
          "Service": "ecs-tasks.amazonaws.com"
        },
        "Effect": "Allow",
        "Sid": ""
      }
    ]
}
  EOF
  managed_policy_arns         = ["arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"]
}

resource "awscc_ecs_service" "nginx" {
  service_name    = "nginx_service"
  cluster         = awscc_ecs_cluster.this.id
  task_definition = aws_ecs_task_definition.nginx.arn
  launch_type     = "FARGATE"
  desired_count   = 1

  network_configuration = {
    awsvpc_configuration = {
      assign_public_ip = "ENABLED"
      subnets          = ["${data.awscc_ec2_subnet.subnet.subnet_id}"]
    }
  }

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
  depends_on = [awscc_iam_role.nginx]
}

Schema

Optional

Read-Only

Nested Schema for capacity_provider_strategy

Optional:

Nested Schema for deployment_configuration

Optional:

Nested Schema for deployment_configuration.alarms

Required:

Nested Schema for deployment_configuration.deployment_circuit_breaker

Required:

Nested Schema for deployment_controller

Optional:

Nested Schema for load_balancers

Optional:

Nested Schema for network_configuration

Optional:

Nested Schema for network_configuration.awsvpc_configuration

Optional:

Nested Schema for placement_constraints

Required:

Optional:

Nested Schema for placement_strategies

Required:

Optional:

Nested Schema for service_connect_configuration

Required:

Optional:

Nested Schema for service_connect_configuration.log_configuration

Optional:

Nested Schema for service_connect_configuration.log_configuration.secret_options

Required:

Nested Schema for service_connect_configuration.services

Required:

Optional:

Nested Schema for service_connect_configuration.services.client_aliases

Required:

Optional:

Nested Schema for service_connect_configuration.services.timeout

Optional:

Nested Schema for service_connect_configuration.services.tls

Required:

Optional:

Nested Schema for service_connect_configuration.services.tls.issuer_certificate_authority

Optional:

Nested Schema for service_registries

Optional:

Nested Schema for tags

Optional:

Nested Schema for volume_configurations

Required:

Optional:

Nested Schema for volume_configurations.managed_ebs_volume

Required:

Optional:

Nested Schema for volume_configurations.managed_ebs_volume.tag_specifications

Required:

Optional:

Nested Schema for volume_configurations.managed_ebs_volume.tag_specifications.tags

Optional:

Import

Import is supported using the following syntax:

$ terraform import awscc_ecs_service.example <resource ID>