Skip to content

Commit c1ff28e

Browse files
author
Premdeep Saini
committed
docs: update readme
1 parent db975e1 commit c1ff28e

File tree

1 file changed

+152
-6
lines changed

1 file changed

+152
-6
lines changed

README.md

Lines changed: 152 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,154 @@
1-
### ECS Terraform Module
1+
## ECS Terraform Module
22

3-
This module provides resources for the setup of ECS cluster. This includes:
3+
Terraform module which creates Amazon ECS cluster with EC2 launch type
44

5-
- ECS cluster
6-
- Capacity Providers
7-
- Auto scaling groups
8-
- Launch Configurations
5+
This module creates following resources:
6+
7+
1. ECS cluster
8+
2. Capacity providers
9+
3. Autoscaling groups for EC2
10+
4. Launch configuration for EC2
11+
12+
13+
### Usage
14+
```
15+
module "app_cluster" {
16+
source = "git::https://github.com/gaussb-labs/terraform-aws-ecs-cluster-module.git?ref=v1.1.2"
17+
environment = "production"
18+
cluster_name = "app_cluster"
19+
launch_configs = [
20+
{
21+
name = "java_application"
22+
image_id = "ami-040d909ea4e56f8f3"
23+
instance_type = "t3a.medium"
24+
user_data_base64 = <base64 encoded userdata>
25+
iam_instance_profile_name = "ecs_agent_access_instance_profile"
26+
security_group_ids = ["sg-01", "sg-02"]
27+
},
28+
{
29+
name = "rails_application"
30+
image_id = "ami-040d909ea4e56f8f3"
31+
instance_type = "t3a.medium"
32+
user_data_base64 = <base64 encoded userdata>
33+
iam_instance_profile_name = "ecs_agent_access_instance_profile"
34+
security_group_ids = ["sg-03", "sg-04"]
35+
}
36+
]
37+
asg = [
38+
{
39+
name = "java_application"
40+
vpc_zone_identifier = ["subnet_id_1", "subnet_id_2"]
41+
health_check_type = "EC2"
42+
health_check_grace_period = 10
43+
max_size = 3
44+
min_size = 1
45+
protect_from_scale_in = true
46+
additional_tags = []
47+
},
48+
{
49+
name = "rails_application"
50+
vpc_zone_identifier = ["subnet_id_1", "subnet_id_2"]
51+
health_check_type = "EC2"
52+
health_check_grace_period = 10
53+
max_size = 2
54+
min_size = 0
55+
protect_from_scale_in = false
56+
additional_tags = []
57+
}
58+
]
59+
capacity_providers = [
60+
{
61+
name = "java_application"
62+
target_capacity = 100
63+
managed_scaling_status = "ENABLED"
64+
managed_termination_protection = "ENABLED"
65+
},
66+
{
67+
name = "rails_application"
68+
target_capacity = 100
69+
managed_scaling_status = "ENABLED"
70+
managed_termination_protection = "DISABLED"
71+
}
72+
]
73+
}
74+
```
75+
76+
_NOTE:_</br>
77+
_This module doesn't provide the ability to create ECS services and tasks.
78+
This can be created separately and should be closer to the application deployments
79+
rather than the infrastructure deployments._
80+
81+
### Configuration
82+
#### 1. asg
83+
asg is a list of auto-scaling group configuration. This module supports
84+
multiple asg configurations per cluster. This is useful in scenarios where
85+
we need different auto-scaling for different kind of workloads.
86+
`launch_config` is required for auto-scaling group.
87+
88+
89+
#### 2. launch_configs
90+
launch_configs is a list of launch configurations, used by the auto-scaling groups
91+
to spin up new EC2 instances. One launch configuration per auto-scaling group is
92+
supported, although we can specify multiple launch configurations if there are multiple
93+
auto-scaling groups defined.
94+
The launch configuration is linked to the auto-scaling group via the `name` attribute,
95+
so name has to same for both asg and launch configuration.
96+
97+
_`iam_instance_profile_name` is expected by this module. The instance_profile should be created considering
98+
the accesses needed by the ECS agent to interact with the ECS cluster and service._
99+
100+
101+
#### 3. capacity_providers
102+
Configuration block for defining capacity providers in the ECS cluster.
103+
This is needed if you plan to use capacity provider strategy for ECS service.
104+
`asg` and `launch_config` are required for the capacity provider.
105+
106+
107+
### Requirements
108+
109+
| Name | Version |
110+
|----------- |---------- |
111+
| terraform | \>= 1.2.0 |
112+
113+
### Providers
114+
| Name | Version |
115+
|----------- |--------- |
116+
| aws | ~> 4.16 |
117+
| cloudinit | \>=2.2.0 |
118+
119+
### Inputs
120+
121+
| Name | Description |
122+
|--------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------- |
123+
| environment | The cluster deployment environment. environment is added as prefix to the resources generated by this module. |
124+
| cluster_name | Name of ECS cluster. environment is not added to the cluster name. |
125+
| capacity_providers | List of capacity provider configuration. |
126+
| capacity_providers.name | Capacity provider name. This is used by the module to link auto-scaling group, launch configuration and capacity provider. |
127+
| capacity_providers.target_capacity | Target utilisation for the capacity provider. A value between 1 and 100. |
128+
| capacity_providers.managed_scaling_status | Whether auto-scaling is managed by ECS. Valid values are `ENABLED` and `DISABLED`. |
129+
| capacity_providers.managed_termination_protection | Manage container-aware termination of instances in the auto scaling group when scale-in happens. Valid values are `ENABLED` and `DISABLED`. |
130+
| asg | List of auto-scaling group configuration. |
131+
| asg.name | Name of auto-scaling group. |
132+
| asg.vpc_zone_identifier | List of subnet Ids to launch resources in. |
133+
| asg.health_check_type | Controls how health check is done. Valid values are `EC2` and `ELB`. |
134+
| asg.health_check_grace_period | Time in seconds after instance comes up and health check first kicks in. |
135+
| asg.max_size | The maximum capacity auto-scaling group can scale-out to. |
136+
| asg.min_size | The minimum capacity auto-scaling group can scale-in to. |
137+
| asg.protect_from_scale_in | Indicates whether newly launched instances are automatically protected from termination by auto-scaling group when scaling in. |
138+
| asg.additional_tags | List of additional tags. |
139+
| asg.additional_tags.key | Key of the tag. |
140+
| asg.additional_tags.value | Value of the tag. |
141+
| asg.additional_tags.propagate_at_launch | Indicates whether to propagate the tag to the newly launched EC2 instances. |
142+
| launch_configs | List of launch configurations for auto-scaling groups. |
143+
| launch_configs.name | Name of the launch configuration. Should be same as corresponding auto-scaling group name. |
144+
| launch_configs.image_id | AMI Id of the image to use. |
145+
| launch_configs.instance_type | The type of EC2 instance to use. Eg: t3.small |
146+
| launch_configs.user_data_base64 | Base64 encoded userdata. |
147+
| launch_configs.iam_instance_profile_name | Name of the IAM instance profile to attach to the EC2 instance. |
148+
| launch_configs.security_group_ids | List of security group ids to attach to the EC2 instance. | |
149+
150+
### Outputs
151+
No outputs.
152+
153+
### License
154+
MIT Licensed. See [LICENSE](https://github.com/gaussb-labs/terraform-aws-ecs-cluster-module/blob/main/LICENSE) for full details.

0 commit comments

Comments
 (0)