Skip to content

Commit

Permalink
refactor: use dynamic block for alarms config
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzzimmer authored and saefty committed Feb 14, 2024
1 parent cb50edf commit 0dd7d56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ for example.
| <a name="input_create_ecr_repository"></a> [create\_ecr\_repository](#input\_create\_ecr\_repository) | Create an ECR repository for this service. | `bool` | `true` | no |
| <a name="input_create_ingress_security_group"></a> [create\_ingress\_security\_group](#input\_create\_ingress\_security\_group) | Create a security group allowing ingress from target groups to the application ports. Disable this for target groups attached to a Network Loadbalancer. | `bool` | `true` | no |
| <a name="input_deployment_circuit_breaker"></a> [deployment\_circuit\_breaker](#input\_deployment\_circuit\_breaker) | Deployment circuit breaker configuration. | <pre>object({<br> enable = bool<br> rollback = bool<br> })</pre> | <pre>{<br> "enable": false,<br> "rollback": false<br>}</pre> | no |
| <a name="input_deployment_failure_detection_alarms"></a> [deployment\_failure\_detection\_alarms](#input\_deployment\_failure\_detection\_alarms) | CloudWatch alarms used to detect deployment failures. | <pre>object({<br> enable = bool<br> rollback = bool<br> alarm_names = list(string)<br> })</pre> | <pre>{<br> "alarm_names": [],<br> "enable": false,<br> "rollback": false<br>}</pre> | no |
| <a name="input_deployment_maximum_percent"></a> [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | Upper limit (as a percentage of the service's desiredCount) of the number of running tasks that can be running in a service during a deployment. Not valid when using the `DAEMON` scheduling strategy. | `number` | `200` | no |
| <a name="input_deployment_minimum_healthy_percent"></a> [deployment\_minimum\_healthy\_percent](#input\_deployment\_minimum\_healthy\_percent) | Lower limit (as a percentage of the service's desiredCount) of the number of running tasks that must remain running and healthy in a service during a deployment. | `number` | `100` | no |
| <a name="input_desired_count"></a> [desired\_count](#input\_desired\_count) | Desired count of services to be started/running. | `number` | `0` | no |
Expand Down
12 changes: 8 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ resource "aws_ecs_service" "this" {
}
}

alarms {
enable = var.deployment_failure_detection_alarms.enable
rollback = var.deployment_failure_detection_alarms.rollback
alarm_names = var.deployment_failure_detection_alarms.alarm_names
dynamic "alarms" {
for_each = var.deployment_failure_detection_alarms.enable ? [true] : []

content {
enable = var.deployment_failure_detection_alarms.enable
rollback = var.deployment_failure_detection_alarms.rollback
alarm_names = var.deployment_failure_detection_alarms.alarm_names
}
}

dynamic "load_balancer" {
Expand Down
7 changes: 4 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ variable "deployment_failure_detection_alarms" {
rollback = false
alarm_names = []
}
description = "Deployment circuit breaker configuration."

description = "CloudWatch alarms used to detect deployment failures."
type = object({
enable = optional(bool, true)
enable = bool
rollback = bool
alarm_names = optional(list(string), [])
alarm_names = list(string)
})
}

Expand Down

0 comments on commit 0dd7d56

Please sign in to comment.