|
1 |
| -# aws/ecs/service-only - EC2 Container Service Service/Task |
2 |
| -This module is used to create an ECS service as well as task definition |
| 1 | +# ECS Service |
3 | 2 |
|
4 |
| -## What this does |
| 3 | +This module is used to create an ECS service and task definition |
5 | 4 |
|
6 |
| -- Create task definition |
7 |
| -- Create service |
| 5 | +# Terraform Registry |
8 | 6 |
|
9 |
| -## Required Inputs |
| 7 | +This module is published in [Terraform Registry](https://registry.terraform.io/modules/silinternational/ecs-service/aws/latest). |
10 | 8 |
|
11 |
| -- `cluster_id` - ID for ECS Cluster |
12 |
| -- `service_name` - Name of service, all lowercase, no spaces. |
13 |
| -- `service_env` - Name of environment, used in naming task definition. Ex: `staging` |
14 |
| -- `container_def_json` - JSON for container definition. |
15 |
| -- `desired_count` - Number of tasks to run in service |
16 |
| -- `tg_arn` - Target Group ARN for ALB to register with |
17 |
| -- `lb_container_name` - Container name from `container_def_json` that should be used with target group / alb |
18 |
| -- `lb_container_port` - Container port that should be used with target group / alb |
19 |
| -- `ecsServiceRole_arn` - ARN to IAM ecsServiceRole |
20 |
| -- `volumes` - A list of volume definitions in JSON format that containers in your task may use |
21 |
| - |
22 |
| -### Optional Inputs |
23 |
| - |
24 |
| -- `task_role_arn` - ARN for role to assign to task definition. Default: `blank` |
25 |
| -- `network_mode` - Networking mode for task. Default: `bridge` |
26 |
| -- `deployment_maximum_percent` - Upper limit of tasks that can run during a deployment. Default: `200`% |
27 |
| -- `deployment_minimum_healthy_percent` - Lower limit of tasks that must be running during a deployment. Default: `50`% |
28 |
| - |
29 |
| -## Outputs |
30 |
| - |
31 |
| -- `task_def_arn` - ARN for task definition. |
32 |
| -- `task_def_family` - Family name of task definition. |
33 |
| -- `task_def_revision` - Revision number of task definition. |
34 |
| -- `service_id` - ID/ARN for service |
35 |
| -- `service_name` - Name of service |
36 |
| -- `service_cluster` - Name of ECS cluster service was placed in |
37 |
| -- `service_role` - IAM role for service |
38 |
| -- `service_desired_count` - Desired task count for service |
39 |
| - |
40 |
| -## Usage Example |
| 9 | +# Usage Example |
41 | 10 |
|
42 | 11 | ```hcl
|
43 | 12 | module "ecsservice" {
|
44 |
| - source = "github.com/silinternational/terraform-modules//aws/ecs/service-only" |
45 |
| - cluster_id = "${module.ecscluster.ecs_cluster_id}" |
46 |
| - service_name = "${var.app_name}" |
47 |
| - service_env = "${var.app_env}" |
48 |
| - container_def_json = "${file("task-definition.json")}" |
| 13 | + source = "silinternational/ecs-service/aws" |
| 14 | + version = ">= 0.2.0" |
| 15 | +
|
| 16 | + cluster_id = module.ecscluster.ecs_cluster_id |
| 17 | + service_name = var.app_name |
| 18 | + service_env = var.app_env |
| 19 | + container_def_json = file("task-definition.json") |
49 | 20 | desired_count = 2
|
50 |
| - tg_arn = "${data.terraform_remote_state.cluster.alb_default_tg_arn}" |
| 21 | + tg_arn = data.terraform_remote_state.cluster.alb_default_tg_arn |
51 | 22 | lb_container_name = "app"
|
52 | 23 | lb_container_port = 80
|
53 |
| - ecsServiceRole_arn = "${data.terraform_remote_state.core.ecsServiceRole_arn}" |
54 |
| -
|
55 |
| - volumes = [ |
56 |
| - { |
57 |
| - name = "vol_name" |
58 |
| - efs_volume_configuration = [ |
59 |
| - { |
60 |
| - file_system_id = aws_efs_file_system.vol_name.id |
61 |
| - root_directory = "/" |
62 |
| - }, |
63 |
| - ] |
64 |
| - }, |
65 |
| - ] |
| 24 | + ecsServiceRole_arn = data.terraform_remote_state.core.ecsServiceRole_arn |
66 | 25 | }
|
67 | 26 | ```
|
| 27 | + |
| 28 | +An [example](https://github.com/silinternational/terraform-aws-ecs-service/tree/main/example) usage of this module is included in the source repository. |
0 commit comments