Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the variable and override block to have ASG launch with ABS #73

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 14 additions & 37 deletions autoscaling_group/autoscaling_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
44 changes: 43 additions & 1 deletion autoscaling_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions autoscaling_group/versions.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
2 changes: 1 addition & 1 deletion autoscaling_with_launch_template/autoscaling_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down