diff --git a/README.md b/README.md index d96d55f..ffe0bda 100644 --- a/README.md +++ b/README.md @@ -144,8 +144,10 @@ This repository contains Terraform infrastructure code which creates AWS resourc | [ecs\_ulimits](#input\_ecs\_ulimits) | Container ulimit settings. This is a list of maps, where each map should contain "name", "hardLimit" and "softLimit" |
list(object({| `null` | no | | [enable\_alb](#input\_enable\_alb) | IF an application load balancer should be created | `bool` | `true` | no | | [enable\_asg](#input\_enable\_asg) | If autoscaling should be enabled | `bool` | `false` | no | +| [enable\_cpu\_scaling](#input\_enable\_cpu\_scaling) | If autoscaling should be enabled based on CPU | `bool` | `true` | no | | [enable\_datadog\_log\_forwarder](#input\_enable\_datadog\_log\_forwarder) | Whether we create the lambda to forward logs to datadog | `bool` | `false` | no | | [enable\_datadog\_sidecar](#input\_enable\_datadog\_sidecar) | Whether the datadog sidecar should be added to the task definition | `bool` | `false` | no | +| [enable\_mem\_scaling](#input\_enable\_mem\_scaling) | If autoscaling should be enabled based on Memory | `bool` | `true` | no | | [enable\_nlb](#input\_enable\_nlb) | IF an network load balancer should be created | `bool` | `true` | no | | [enable\_service\_discovery](#input\_enable\_service\_discovery) | Whether the service should be registered with Service Discovery. In order to use Service Disovery, an existing DNS Namespace must exist and be passed in. | `bool` | `false` | no | | [environment](#input\_environment) | The name of the environment | `string` | n/a | yes | diff --git a/autoscaling.tf b/autoscaling.tf index a0f97aa..775b27d 100644 --- a/autoscaling.tf +++ b/autoscaling.tf @@ -17,7 +17,7 @@ resource "aws_appautoscaling_target" "target" { resource "aws_appautoscaling_policy" "auto_scaling_cpu" { - count = var.enable_asg ? 1 : 0 + count = (var.enable_asg && var.enable_cpu_scaling) ? 1 : 0 name = "${var.environment}-${var.name}-cpu-scale" policy_type = "TargetTrackingScaling" resource_id = aws_appautoscaling_target.target[0].resource_id @@ -40,7 +40,7 @@ resource "aws_appautoscaling_policy" "auto_scaling_cpu" { resource "aws_appautoscaling_policy" "auto_scaling_mem" { - count = var.enable_asg ? 1 : 0 + count = (var.enable_asg && var.enable_mem_scaling) ? 1 : 0 name = "${var.environment}-${var.name}-mem-scale" policy_type = "TargetTrackingScaling" resource_id = aws_appautoscaling_target.target[0].resource_id diff --git a/variables.tf b/variables.tf index a0733f0..9733456 100644 --- a/variables.tf +++ b/variables.tf @@ -161,6 +161,19 @@ variable "enable_asg" { default = false } +variable "enable_cpu_scaling" { + description = "If autoscaling should be enabled based on CPU" + type = bool + default = true +} + +variable "enable_mem_scaling" { + description = "If autoscaling should be enabled based on Memory" + type = bool + default = true + +} + variable "asg_max_tasks" { description = "The amount of maximum tasks" type = number
name = string
hardLimit = number
softLimit = number
}))