From 759c543a38407b4131241b4a800c5385f6aa69c2 Mon Sep 17 00:00:00 2001 From: magreenbaum Date: Fri, 20 Dec 2024 10:43:39 -0500 Subject: [PATCH] availability zone distribution --- README.md | 5 +++-- examples/complete/README.md | 4 ++-- examples/complete/versions.tf | 2 +- main.tf | 14 ++++++++++++++ variables.tf | 6 ++++++ versions.tf | 2 +- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 801028f..4704c69 100644 --- a/README.md +++ b/README.md @@ -231,13 +231,13 @@ Note: the default behavior of the module is to create an autoscaling group and l | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.3 | -| [aws](#requirement\_aws) | >= 5.55 | +| [aws](#requirement\_aws) | >= 5.82.1 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.55 | +| [aws](#provider\_aws) | >= 5.82.1 | ## Modules @@ -264,6 +264,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [autoscaling\_group\_tags](#input\_autoscaling\_group\_tags) | A map of additional tags to add to the autoscaling group | `map(string)` | `{}` | no | +| [availability\_zone\_distribution](#input\_availability\_zone\_distribution) | A map of configuration for capacity distribution across availability zones | `any` | `{}` | no | | [availability\_zones](#input\_availability\_zones) | A list of one or more availability zones for the group. Used for EC2-Classic and default subnets when not specified with `vpc_zone_identifier` argument. Conflicts with `vpc_zone_identifier` | `list(string)` | `null` | no | | [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI | `list(any)` | `[]` | no | | [capacity\_rebalance](#input\_capacity\_rebalance) | Indicates whether capacity rebalance is enabled | `bool` | `null` | no | diff --git a/examples/complete/README.md b/examples/complete/README.md index 036a415..978707c 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -30,13 +30,13 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.3 | -| [aws](#requirement\_aws) | >= 5.55 | +| [aws](#requirement\_aws) | >= 5.82.1 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.55 | +| [aws](#provider\_aws) | >= 5.82.1 | ## Modules diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 19f02e4..d80656f 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.55" + version = ">= 5.82.1" } } } diff --git a/main.tf b/main.tf index 5542e35..d6c11db 100644 --- a/main.tf +++ b/main.tf @@ -391,6 +391,13 @@ resource "aws_autoscaling_group" "this" { service_linked_role_arn = var.service_linked_role_arn ignore_failed_scaling_activities = var.ignore_failed_scaling_activities + dynamic "availability_zone_distribution" { + for_each = length(var.availability_zone_distribution) > 0 ? [var.availability_zone_distribution] : [] + content { + capacity_distribution_strategy = availability_zone_distribution.value.capacity_distribution_strategy + } + } + dynamic "initial_lifecycle_hook" { for_each = var.initial_lifecycle_hooks content { @@ -682,6 +689,13 @@ resource "aws_autoscaling_group" "idc" { service_linked_role_arn = var.service_linked_role_arn ignore_failed_scaling_activities = var.ignore_failed_scaling_activities + dynamic "availability_zone_distribution" { + for_each = length(var.availability_zone_distribution) > 0 ? [var.availability_zone_distribution] : [] + content { + capacity_distribution_strategy = availability_zone_distribution.value.capacity_distribution_strategy + } + } + dynamic "initial_lifecycle_hook" { for_each = var.initial_lifecycle_hooks content { diff --git a/variables.tf b/variables.tf index 81f4c14..2f73516 100644 --- a/variables.tf +++ b/variables.tf @@ -49,6 +49,12 @@ variable "availability_zones" { default = null } +variable "availability_zone_distribution" { + description = "A map of configuration for capacity distribution across availability zones" + type = any + default = {} +} + variable "vpc_zone_identifier" { description = "A list of subnet IDs to launch resources in. Subnets automatically determine which availability zones the group will reside. Conflicts with `availability_zones`" type = list(string) diff --git a/versions.tf b/versions.tf index 19f02e4..d80656f 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.55" + version = ">= 5.82.1" } } }