/terraform-aws-autoscaling

A terraform module which provisions an auto scaling group along with its launch template

Primary LanguageHCLApache License 2.0Apache-2.0

terraform-aws-autoscaling

A terraform module which provisions an auto scaling group along with its launch configuration

Conventions

  • the auto scaling group will have Service, Cluster, Environment, and ProductDomain tags by default, which are propagated to all instances it spawns

Behaviour

  • To specify on-demand instance types, use the launch_template_overrides variable. Auto Scaling will launch instances based on the order of preference specified in that list. ["c5.large", "c4.large", "m5.large"] means the ASG will always try to launch c5.large if it's available, falling back to c4.large if it's not available, and falling back to m5.large if the previous two aren't available
  • On the first deployment, this module will provision an ASG with a launch template that select the most recent AMI that passes through the given image_filters
  • Each time there's a change in the values of the module.asg_name's keepers (e.g. security group, AMI ID), a new ASG will be provisioned by terraform, and the old one will later be destroyed (doing the "simple swap" deployment strategy).
  • When there's a change in launch template parameters' values, terraform will create a new launch template version unless the new configuration is already the same as the latest version of the launch template (e.g. when the launch template had been updated externally).

Migration from pre-launch-template versions

terraform init
terraform state rm module.<this module name in your terraform code>.module.random_lc
terraform apply

Switching between plain launch template and mixed instance policy

switching to plain launch template

module "asg" {
  source = "github.com/traveloka/terraform-aws-autoscaling?ref=v0.3.1"
  # ...
  use_mixed_instance_policy = false
  launch_template_overrides = [
    {
      "instance_type" = "c4.large" # this (the first element) will be the launch template's instance type
    },
    {
      "instance_type" = "t3.medium"
    },
  ]
}

switching to mixed instance policy

module "asg" {
  source = "github.com/traveloka/terraform-aws-autoscaling?ref=v0.3.1"
  # ...
  use_mixed_instance_policy = true
}

Authors

License

See LICENSE for full details.