Skip to content

Commit dcdffa0

Browse files
Added dynamic block for cloudwatch alarms (#75)
* Added dynamic block for cloudwatch alarms Signed-off-by: Mohammed Alkatheeri <[email protected]> * chore: update pre-commit, readme and changelog * Supress tflint messages Signed-off-by: Mohammed Alkatheeri <[email protected]> --------- Signed-off-by: Mohammed Alkatheeri <[email protected]>
1 parent dae529d commit dcdffa0

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=500']
@@ -18,7 +18,7 @@ repos:
1818
args: ['--allow-missing-credentials']
1919
- id: trailing-whitespace
2020
- repo: https://github.com/antonbabenko/pre-commit-terraform
21-
rev: v1.81.0
21+
rev: v1.96.2
2222
hooks:
2323
- id: terraform_fmt
2424
- id: terraform_docs

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8-
- fix: protocol set to HTTP by default
9-
- fix: setting container_name is now mandatory to utilise multiple container names set externally to module
10-
- chore: upgrade to 5.x compatibility
8+
- Added dynamic block for cloudwatch alarms
9+
10+
11+
<a name="8.0.0"></a>
12+
## [8.0.0] - 2023-07-24
13+
14+
- Upgrade to 5.x + Fixes ([#74](https://github.com/umotif-public/terraform-aws-ecs-fargate/issues/74))
1115

1216

1317
<a name="7.0.0"></a>
@@ -278,7 +282,8 @@ All notable changes to this project will be documented in this file.
278282
- Initial commit
279283

280284

281-
[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/7.0.0...HEAD
285+
[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/8.0.0...HEAD
286+
[8.0.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/7.0.0...8.0.0
282287
[7.0.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.7.1...7.0.0
283288
[6.7.1]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.7.0...6.7.1
284289
[6.7.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.6.0...6.7.0

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module "ecs-fargate" {
7979

8080
Module managed by [uMotif](https://github.com/umotif-public/).
8181

82-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
82+
<!-- BEGIN_TF_DOCS -->
8383
## Requirements
8484

8585
| Name | Version |
@@ -135,6 +135,7 @@ No modules.
135135
| <a name="input_cpu_architecture"></a> [cpu\_architecture](#input\_cpu\_architecture) | cpu architecture for the task | `string` | `"X86_64"` | no |
136136
| <a name="input_create_repository_credentials_iam_policy"></a> [create\_repository\_credentials\_iam\_policy](#input\_create\_repository\_credentials\_iam\_policy) | Set to true if you are specifying `repository_credentials` variable, it will attach IAM policy with necessary permissions to task role. | `bool` | `false` | no |
137137
| <a name="input_deny_egress_to_anywhere"></a> [deny\_egress\_to\_anywhere](#input\_deny\_egress\_to\_anywhere) | When this parameter is true, no default egress rule will be created | `bool` | `false` | no |
138+
| <a name="input_deployment_alarms"></a> [deployment\_alarms](#input\_deployment\_alarms) | Information about the CloudWatch alarms | <pre>list(object({<br/> alarm_names = list(string)<br/> rollback = bool<br/> enable = bool<br/> }))</pre> | `[]` | no |
138139
| <a name="input_deployment_controller_type"></a> [deployment\_controller\_type](#input\_deployment\_controller\_type) | Type of deployment controller. Valid values: CODE\_DEPLOY, ECS, EXTERNAL. Default: ECS. | `string` | `"ECS"` | no |
139140
| <a name="input_deployment_maximum_percent"></a> [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | The upper limit of the number of running tasks that can be running in a service during a deployment | `number` | `200` | no |
140141
| <a name="input_deployment_minimum_healthy_percent"></a> [deployment\_minimum\_healthy\_percent](#input\_deployment\_minimum\_healthy\_percent) | The lower limit of the number of running tasks that must remain running and healthy in a service during a deployment | `number` | `50` | no |
@@ -209,7 +210,7 @@ No modules.
209210
| <a name="output_task_definition_name"></a> [task\_definition\_name](#output\_task\_definition\_name) | The name of the task definition created |
210211
| <a name="output_task_role_arn"></a> [task\_role\_arn](#output\_task\_role\_arn) | The Amazon Resource Name (ARN) specifying the ECS service role. |
211212
| <a name="output_task_role_name"></a> [task\_role\_name](#output\_task\_role\_name) | The name of the Fargate task service role. |
212-
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
213+
<!-- END_TF_DOCS -->
213214

214215
## License
215216

main.tf

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ resource "aws_security_group_rule" "egress_service" {
106106
resource "aws_lb_target_group" "task" {
107107
for_each = var.load_balanced ? { for tg in var.target_groups : tg.target_group_name => tg } : {}
108108

109+
# tflint-ignore: terraform_deprecated_lookup
109110
name = lookup(each.value, "target_group_name")
110111
vpc_id = var.vpc_id
111112
protocol = var.task_container_protocol
@@ -137,6 +138,7 @@ resource "aws_lb_target_group" "task" {
137138
tags = merge(
138139
var.tags,
139140
{
141+
# tflint-ignore: terraform_deprecated_lookup
140142
Name = lookup(each.value, "target_group_name")
141143
},
142144
)
@@ -289,11 +291,23 @@ resource "aws_ecs_service" "service" {
289291
}
290292
}
291293

294+
dynamic "alarms" {
295+
for_each = var.deployment_alarms != null ? var.deployment_alarms : []
296+
content {
297+
alarm_names = try(alarms.value.alarm_names, [])
298+
enable = try(alarms.value.enable, false)
299+
rollback = try(alarms.value.rollback, false)
300+
}
301+
}
302+
292303
dynamic "load_balancer" {
304+
# tflint-ignore: terraform_deprecated_lookup
293305
for_each = var.load_balanced ? var.target_groups : []
294306
content {
295-
container_name = try(load_balancer.value, "container_name") != "" ? lookup(load_balancer.value, "container_name") : var.name_prefix
296-
container_port = lookup(load_balancer.value, "container_port", var.task_container_port)
307+
# tflint-ignore: terraform_deprecated_lookup
308+
container_name = try(load_balancer.value, "container_name") != "" ? lookup(load_balancer.value, "container_name") : var.name_prefix
309+
container_port = lookup(load_balancer.value, "container_port", var.task_container_port)
310+
# tflint-ignore: terraform_deprecated_lookup
297311
target_group_arn = aws_lb_target_group.task[lookup(load_balancer.value, "target_group_name")].arn
298312
}
299313
}

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ variable "capacity_provider_strategy" {
229229
default = []
230230
}
231231

232+
variable "deployment_alarms" {
233+
type = list(object({
234+
alarm_names = list(string)
235+
rollback = bool
236+
enable = bool
237+
}))
238+
description = "Information about the CloudWatch alarms"
239+
default = []
240+
}
241+
232242
variable "placement_constraints" {
233243
type = list(any)
234244
description = "(Optional) A set of placement constraints rules that are taken into consideration during task placement. Maximum number of placement_constraints is 10. This is a list of maps, where each map should contain \"type\" and \"expression\""

0 commit comments

Comments
 (0)