-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.yaml
289 lines (246 loc) · 9.55 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name : Terraform AWS ECS
# License of this project
license: "APACHE"
# Canonical GitHub repo
github_repo: clouddrove/terraform-aws-ecs
# Badges to display
badges:
- name: "Latest Release"
image: "https://img.shields.io/github/release/clouddrove/terraform-aws-ecs.svg"
url: "https://github.com/clouddrove/terraform-aws-ecs/releases/latest"
- name: "tfsec"
image: "https://github.com/clouddrove/terraform-aws-ecs/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-aws-ecs/actions/workflows/tfsec.yml"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"
- name: "Changelog"
image: "https://img.shields.io/badge/Changelog-blue"
url: "CHANGELOG.md"
prerequesties:
- name: Terraform
url: https://learn.hashicorp.com/terraform/getting-started/install.html
version: ">= 1.6.6"
providers:
- name: aws
url: https://aws.amazon.com/
version: ">= 5.31.0"
# description of this project
description: |-
Terraform module to create ECS on AWS.
# How to use this project
# How to use this project
usage : |-
### Network Mode AWSVPC Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "ecs" {
source = "clouddrove/ecs/aws"
version = "1.3.0"
## Tags
name = "ecs-awsvpc"
repository = "https://github.com/clouddrove/terraform-aws-ecs"
environment = "test"
label_order = ["name", "environment"]
enabled = false # set to true after VPC, Subnets, Security Groups, KMS Key and Key Pair gets created
## Network
vpc_id = module.vpc.vpc_id
subnet_ids = module.subnets.private_subnet_id
additional_security_group_ids = [module.ssh.security_group_ids, module.http_https.security_group_ids]
ec2 = module.ec2.private_ip
instance_count = module.ec2.instance_count
listener_certificate_arn = module.acm.arn
## EC2
autoscaling_policies_enabled = false
key_name = module.keypair.name
image_id = "ami-001085c9389955bb6"
instance_type = "t3.medium"
min_size = 1
max_size = 3
volume_size = 8
lb_security_group = module.ssh.security_group_ids
service_lb_security_group = [module.http_https.security_group_ids]
cloudwatch_prefix = "ecs-logs"
## ECS Cluster
ec2_cluster_enabled = true
ecs_settings_enabled = "enabled"
## Schedule
scheduler_down = "0 19 * * MON-FRI"
scheduler_up = "0 6 * * MON-FRI"
schedule_enabled = true
spot_schedule_enabled = true
min_size_scaledown = 0
max_size_scaledown = 1
scale_up_desired = 2
scale_down_desired = 1
spot_min_size_scaledown = 0
spot_max_size_scaledown = 1
spot_scale_up_desired = 2
spot_scale_down_desired = 1
## Spot
spot_enabled = true
spot_min_size = 1
spot_max_size = 3
spot_price = "0.10"
spot_instance_type = "m5.xlarge"
## Health Checks
memory_reservation_high_threshold_percent = 75
memory_reservation_low_threshold_percent = 50
health_check_type = "EC2"
## EBS Encryption
ebs_encryption = true
kms_key_arn = module.kms_key.key_arn
## Service
ec2_service_enabled = true
ec2_awsvpc_enabled = true
desired_count = 10
propagate_tags = "TASK_DEFINITION"
lb_subnet = module.subnets.private_subnet_id
scheduling_strategy = "REPLICA"
container_name = "nginx"
container_port = 80
target_type = "ip"
## Task Definition
ec2_td_enabled = true
network_mode = "awsvpc"
ipc_mode = "task"
pid_mode = "task"
cpu = 512
memory = 1024
file_name = "./td-ec2-awsvpc.json"
container_log_group_name = "ec2-container-logs"
}
```
### Network Mode BRIDGE Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "ecs" {
source = "clouddrove/ecs/aws"
version = "1.3.0"
## Tags
name = "ecs-bridge"
repository = "https://github.com/clouddrove/terraform-aws-ecs"
environment = "test"
label_order = ["name", "environment"]
enabled = false # set to true after VPC, Subnets, Security Groups, KMS Key and Key Pair gets created
## Network
vpc_id = module.vpc.vpc_id
subnet_ids = module.subnets.private_subnet_id
additional_security_group_ids = [module.ssh.security_group_ids, module.http_https.security_group_ids]
ec2 = module.ec2.instance_id
instance_count = module.ec2.instance_count
listener_certificate_arn = module.acm.arn
## EC2
autoscaling_policies_enabled = true
key_name = module.keypair.name
image_id = "ami-001085c9389955bb6"
instance_type = "t3.medium"
min_size = 1
max_size = 3
volume_size = 8
lb_security_group = module.ssh.security_group_ids
service_lb_security_group = [module.http_https.security_group_ids]
cloudwatch_prefix = "ecs-logs"
## ECS Cluster
ec2_cluster_enabled = true
ecs_settings_enabled = "enabled"
## Schedule
scheduler_down = "0 19 * * MON-FRI"
scheduler_up = "0 6 * * MON-FRI"
schedule_enabled = true
min_size_scaledown = 0
max_size_scaledown = 1
scale_up_desired = 2
scale_down_desired = 1
spot_min_size_scaledown = 0
spot_max_size_scaledown = 1
spot_scale_up_desired = 2
spot_scale_down_desired = 1
## Spot
spot_enabled = true
spot_min_size = 1
spot_max_size = 3
spot_price = "0.10"
spot_instance_type = "m5.xlarge"
## Health Checks
memory_reservation_high_threshold_percent = 75
memory_reservation_low_threshold_percent = 50
health_check_type = "EC2"
## EBS Encryption
ebs_encryption = true
kms_key_arn = module.kms_key.key_arn
## Service
ec2_service_enabled = true
desired_count = 6
propagate_tags = "TASK_DEFINITION"
lb_subnet = module.subnets.public_subnet_id
scheduling_strategy = "REPLICA"
container_name = "nginx"
container_port = 80
target_type = "instance"
## Task Definition
ec2_td_enabled = true
network_mode = "bridge"
ipc_mode = "task"
pid_mode = "task"
cpu = 512
memory = 1024
file_name = "./td-ec2-bridge.json"
container_log_group_name = "ec2-container-logs"
}
```
### Fargate Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "ecs" {
source = "clouddrove/ecs/aws"
version = "1.3.0"
## Tags
name = "ecs-fargate"
repository = "https://github.com/clouddrove/terraform-aws-ecs"
environment = "test"
label_order = ["name", "environment"]
enabled = false # set to true after VPC, Subnets, Security Groups, KMS Key and Key Pair gets created
## Network
vpc_id = module.vpc.vpc_id
subnet_ids = module.subnets.private_subnet_id
## EC2
lb_security_group = module.sg_lb.security_group_ids
service_lb_security_group = [module.sg_lb.security_group_ids, module.http_https.security_group_ids]
ec2 = module.ec2.private_ip
instance_count = module.ec2.instance_count
lb_subnet = module.subnets.public_subnet_id
listener_certificate_arn = module.acm.arn
## Fargate Cluster
fargate_cluster_enabled = true
ecs_settings_enabled = "enabled"
fargate_cluster_cp = ["FARGATE", "FARGATE_SPOT"]
## Service
fargate_service_enabled = true
desired_count = 4
assign_public_ip = true
propagate_tags = "TASK_DEFINITION"
scheduling_strategy = "REPLICA"
container_name = "nginx"
container_port = 80
target_type = "ip"
weight_simple = 1
weight_spot = 2
base = 1
fargate_capacity_provider_simple = "FARGATE"
fargate_capacity_provider_spot = "FARGATE_SPOT"
## Task Definition
fargate_td_enabled = true
cpu = 512
network_mode = "bridge"
memory = 1024
file_name = "./td-fargate.json"
container_log_group_name = "fargate-container-logs"
}
```