diff --git a/autoscaling_group/autoscaling_group.tf b/autoscaling_group/autoscaling_group.tf index 0c92994..d7e4682 100644 --- a/autoscaling_group/autoscaling_group.tf +++ b/autoscaling_group/autoscaling_group.tf @@ -19,6 +19,7 @@ resource "aws_autoscaling_group" "default" { wait_for_elb_capacity = var.wait_for_elb_capacity protect_from_scale_in = var.protect_from_scale_in capacity_rebalance = var.capacity_rebalance + dynamic "initial_lifecycle_hook" { for_each = var.initial_lifecycle_hooks @@ -38,44 +39,20 @@ resource "aws_autoscaling_group" "default" { } override { - instance_type = length(var.instance_types) >= 1 ? var.instance_types.0 : "" - } - - override { - instance_type = length(var.instance_types) >= 2 ? var.instance_types.1 : "" - } - - override { - instance_type = length(var.instance_types) >= 3 ? var.instance_types.2 : "" - } - - override { - instance_type = length(var.instance_types) >= 4 ? var.instance_types.3 : "" - } - - override { - instance_type = length(var.instance_types) >= 5 ? var.instance_types.4 : "" - } - - override { - instance_type = length(var.instance_types) >= 6 ? var.instance_types.5 : "" - } - - override { - instance_type = length(var.instance_types) >= 7 ? var.instance_types.6 : "" - } - - override { - instance_type = length(var.instance_types) >= 8 ? var.instance_types.7 : "" - } - - override { - instance_type = length(var.instance_types) >= 9 ? var.instance_types.8 : "" - } - - override { - instance_type = length(var.instance_types) >= 10 ? var.instance_types.9 : "" + instance_requirements { + burstable_performance = var.burstable_performance + excluded_instance_types = var.excluded_instance_types + instance_generations = var.instance_generations + memory_mib { + min = var.memory_mib + } + vcpu_count { + min = var.vcpu_count + } + cpu_manufacturers = var.cpu_manufacturers + } } + } instances_distribution { on_demand_allocation_strategy = var.on_demand_allocation_strategy diff --git a/autoscaling_group/variables.tf b/autoscaling_group/variables.tf index 8ce0d5c..cb8eb98 100644 --- a/autoscaling_group/variables.tf +++ b/autoscaling_group/variables.tf @@ -83,6 +83,48 @@ variable "instance_types" { type = list(string) } +variable "burstable_performance" { + description = "Enable burstable performance instances" + type = string + default = "included" +} + +variable "excluded_instance_types" { + description = "List of excluded instance types" + type = list(string) + default = [] +} + +variable "cpu_manufacturers" { + description = "CPU manufacturer for instance selection" + type = list(string) + default = [] +} + +variable "architecture_type" { + description = "Architecture type for instance selection" + type = string + default = "x86_64" +} + +variable "instance_generations" { + description = "Instance generation for instance selection" + type = list(string) + default = ["current"] +} + +variable "memory_mib" { + description = "Minimum memory (in MiB) for ABS instance selection" + type = number + default = 2048 +} + +variable "vcpu_count" { + description = "Minimum number of vCPUs for ABS instance selection" + type = number + default = 2 +} + variable "launch_template_id" { description = "Template ID" } @@ -112,7 +154,7 @@ variable "min_elb_capacity" { variable "on_demand_allocation_strategy" { description = "Strategy to use when launching on-demand instances. Valid values: prioritized. Default: prioritized" - default = "prioritized" + default = "lowest-price" } variable "on_demand_base_capacity" { diff --git a/autoscaling_group/versions.tf b/autoscaling_group/versions.tf index 6bfa801..58d0cfc 100644 --- a/autoscaling_group/versions.tf +++ b/autoscaling_group/versions.tf @@ -1,10 +1,10 @@ terraform { - required_version = ">= 0.13" + required_version = "~> 0.13" required_providers { aws = { source = "hashicorp/aws" - version = "3.76.1" + version = "~> 4.60.0" } } } diff --git a/autoscaling_with_launch_template/autoscaling_group.tf b/autoscaling_with_launch_template/autoscaling_group.tf index 7f84caa..a0804ee 100644 --- a/autoscaling_with_launch_template/autoscaling_group.tf +++ b/autoscaling_with_launch_template/autoscaling_group.tf @@ -66,7 +66,7 @@ resource "aws_autoscaling_group" "default" { } } - + instances_distribution { on_demand_allocation_strategy = var.on_demand_allocation_strategy on_demand_base_capacity = var.on_demand_base_capacity