An open API service indexing awesome lists of open source software.

https://github.com/launchbynttdata/tf-aws-module_primitive-ecs_service


https://github.com/launchbynttdata/tf-aws-module_primitive-ecs_service

Last synced: 13 days ago
JSON representation

Awesome Lists containing this project

README

          

# tf-aws-module_primitive-ecs_service

This module provides a primitive Terraform module for creating an Amazon ECS service with support for various configurations including load balancers, service discovery, and more.

## Features

- Supports Fargate and EC2 launch types
- Configurable network settings with subnets and security groups
- Load balancer integration
- Service Connect for service-to-service communication
- Service discovery registries
- Capacity provider strategies
- Deployment configurations with circuit breakers and alarms
- Volume configurations for EBS attachments
- ECS Exec support
- Comprehensive tagging and managed tags

## Usage

```hcl
module "ecs_service" {
source = "path/to/module"

name = "my-ecs-service"
cluster = aws_ecs_cluster.example.arn
task_definition = aws_ecs_task_definition.example.arn

desired_count = 2
launch_type = "FARGATE"

network_configuration = {
subnets = [aws_subnet.example.id]
security_groups = [aws_security_group.example.id]
assign_public_ip = false
}

tags = {
Environment = "dev"
}
}
```

## Resources Created

- 1 ECS Service
- 1 Service Discovery Service (data source, if Service Connect lookup is configured)

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0 |
| [aws](#requirement\_aws) | ~> 5.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_ecs_service.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service) | resource |
| [aws_service_discovery_service.service_connect](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_discovery_service) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [name](#input\_name) | Name for the ECS service | `string` | n/a | yes |
| [tags](#input\_tags) | A map of tags to add to the ECS service | `map(string)` | `{}` | no |
| [cluster](#input\_cluster) | ARN of the ECS cluster where this service will be placed | `string` | n/a | yes |
| [task\_definition](#input\_task\_definition) | The family and revision (family:revision) or full ARN of the task definition to run in your service | `string` | n/a | yes |
| [desired\_count](#input\_desired\_count) | The number of instances of the task definition to place and keep running | `number` | `1` | no |
| [launch\_type](#input\_launch\_type) | The launch type on which to run your service. Valid values: EC2, FARGATE, EXTERNAL | `string` | `"FARGATE"` | no |
| [platform\_version](#input\_platform\_version) | The platform version on which to run your service. Only applicable for launch\_type set to FARGATE | `string` | `"LATEST"` | no |
| [iam\_role](#input\_iam\_role) | The ARN of an IAM role that allows your Amazon ECS service to make calls to other AWS services | `string` | `null` | no |
| [enable\_execute\_command](#input\_enable\_execute\_command) | Whether to enable Amazon ECS Exec for the tasks in the service | `bool` | `false` | no |
| [enable\_ecs\_managed\_tags](#input\_enable\_ecs\_managed\_tags) | Whether to enable Amazon ECS managed tags for the tasks in the service | `bool` | `false` | no |
| [propagate\_tags](#input\_propagate\_tags) | Whether to propagate the tags from the task definition or the service to the tasks | `string` | `"SERVICE"` | no |
| [health\_check\_grace\_period\_seconds](#input\_health\_check\_grace\_period\_seconds) | Health check grace period in seconds for the service when using load balancers | `number` | `null` | no |
| [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | Whether to wait for the service to reach a steady state before continuing | `bool` | `false` | no |
| [force\_new\_deployment](#input\_force\_new\_deployment) | Whether to force a new task deployment of the service | `bool` | `false` | no |
| [network\_configuration](#input\_network\_configuration) | Network configuration for the ECS service |

object({
subnets = list(string)
security_groups = list(string)
assign_public_ip = optional(bool, false)
})
| `null` | no |
| [load\_balancer](#input\_load\_balancer) | Load balancer configuration for the service |
list(object({
target_group_arn = string
container_name = string
container_port = number
}))
| `[]` | no |
| [service\_connect\_configuration](#input\_service\_connect\_configuration) | Service Connect configuration for the service |
object({
enabled = bool
namespace = optional(string)
log_configuration = optional(object({
log_driver = string
options = map(string)
}))
service = optional(object({
client_alias = object({
dns_name = string
port = number
})
discovery_name = string
port_name = string
tls = optional(object({
issuer_cert_authority = object({
aws_pca_authority_arn = string
})
kms_key = optional(string)
role_arn = optional(string)
}))
}))
})
| `null` | no |
| [service\_registries](#input\_service\_registries) | Service discovery registries for the service |
list(object({
registry_arn = string
port = optional(number)
container_name = optional(string)
container_port = optional(number)
}))
| `[]` | no |
| [service\_connect\_registry\_arn](#input\_service\_connect\_registry\_arn) | ARN of the Service Connect service to register in service registries for external discovery | `string` | `null` | no |
| [service\_connect\_registry\_port](#input\_service\_connect\_registry\_port) | Port value for the Service Connect service registry entry | `number` | `null` | no |
| [service\_connect\_registry\_container\_name](#input\_service\_connect\_registry\_container\_name) | Container name for the Service Connect service registry entry | `string` | `null` | no |
| [service\_connect\_registry\_container\_port](#input\_service\_connect\_registry\_container\_port) | Container port for the Service Connect service registry entry | `number` | `null` | no |
| [service\_connect\_discovery\_name](#input\_service\_connect\_discovery\_name) | Discovery name of the Service Connect service to lookup (should match service.discovery\_name in service\_connect\_configuration) | `string` | `null` | no |
| [service\_connect\_namespace\_id](#input\_service\_connect\_namespace\_id) | Namespace ID for Service Connect service discovery lookup | `string` | `null` | no |
| [capacity\_provider\_strategy](#input\_capacity\_provider\_strategy) | Capacity provider strategy to use for the service |
list(object({
capacity_provider = string
weight = number
base = optional(number, 0)
}))
| `[]` | no |
| [deployment\_configuration](#input\_deployment\_configuration) | Deployment configuration for the service |
object({
maximum_percent = optional(number, 200)
minimum_healthy_percent = optional(number, 100)
deployment_circuit_breaker = optional(object({
enable = bool
rollback = bool
}))
alarms = optional(object({
alarm_names = list(string)
enable = bool
rollback = bool
}))
deployment_attempts = optional(number, 2)
})
|
{
"maximum_percent": 200,
"minimum_healthy_percent": 100
}
| no |
| [placement\_constraints](#input\_placement\_constraints) | Placement constraints for the service |
list(object({
type = string
expression = optional(string)
}))
| `[]` | no |
| [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | Placement strategy for the service |
list(object({
type = string
field = optional(string)
}))
| `[]` | no |
| [volume\_configuration](#input\_volume\_configuration) | Configuration for EBS volumes that are attached to tasks |
object({
name = string
managed_ebs_volume = object({
role_arn = string
encrypted = optional(bool, true)
file_system_type = optional(string, "ext4")
iops = optional(number)
kms_key_id = optional(string)
size_in_gb = optional(number, 20)
snapshot_id = optional(string)
throughput = optional(number)
volume_type = optional(string, "gp3")
tag_specifications = optional(list(object({
resource_type = string
tags = map(string)
})), [])
})
})
| `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| [id](#output\_id) | The ID of the ECS service |
| [name](#output\_name) | The name of the ECS service |
| [cluster](#output\_cluster) | The cluster the ECS service is associated with |
| [desired\_count](#output\_desired\_count) | The desired number of tasks for the ECS service |
| [task\_definition](#output\_task\_definition) | The task definition ARN used by the ECS service |
| [launch\_type](#output\_launch\_type) | The launch type of the ECS service |
| [platform\_version](#output\_platform\_version) | The platform version of the ECS service |
| [deployment\_configuration](#output\_deployment\_configuration) | The deployment configuration of the ECS service |
| [network\_configuration](#output\_network\_configuration) | The network configuration of the ECS service |
| [load\_balancer\_configuration](#output\_load\_balancer\_configuration) | The load balancer configuration of the ECS service |
| [service\_connect\_configuration](#output\_service\_connect\_configuration) | The service connect configuration of the ECS service |
| [service\_registries](#output\_service\_registries) | The effective service registries configuration of the ECS service (includes Service Connect registry if configured) |
| [service\_connect\_service\_arn](#output\_service\_connect\_service\_arn) | ARN of the Service Connect service discovered via data source (if lookup is configured) |
| [service\_connect\_service\_discovery\_name](#output\_service\_connect\_service\_discovery\_name) | Discovery name of the Service Connect service (from configuration) |
| [capacity\_provider\_strategy](#output\_capacity\_provider\_strategy) | The capacity provider strategy of the ECS service |
| [placement\_constraints](#output\_placement\_constraints) | The placement constraints of the ECS service |
| [placement\_strategy](#output\_placement\_strategy) | The placement strategy of the ECS service |
| [volume\_configuration](#output\_volume\_configuration) | The volume configuration of the ECS service |
| [enable\_execute\_command](#output\_enable\_execute\_command) | Whether ECS Exec is enabled for the service |
| [enable\_ecs\_managed\_tags](#output\_enable\_ecs\_managed\_tags) | Whether ECS managed tags are enabled for the service |
| [propagate\_tags](#output\_propagate\_tags) | How tags are propagated to tasks |
| [tags](#output\_tags) | A map of tags assigned to the ECS service |
| [tags\_all](#output\_tags\_all) | A map of tags assigned to the resource, including provider default\_tags |
| [service\_details](#output\_service\_details) | Comprehensive details about the ECS service for integration purposes |
| [service\_configuration](#output\_service\_configuration) | Summary of the ECS service configuration |