All Projects → traveloka → terraform-aws-autoscaling

traveloka / terraform-aws-autoscaling

Licence: Apache-2.0 License
A terraform module which provisions an auto scaling group along with its launch template

Programming Languages

HCL
1544 projects

Projects that are alternatives of or similar to terraform-aws-autoscaling

terraform-aws-waf-webacl-supporting-resources
A module to create several resources needed by AWS WAF WebACL.
Stars: ✭ 25 (-21.87%)
Mutual labels:  hcl, terraform-module
terraform-linode-k8s
Kubernetes installer for Linode
Stars: ✭ 63 (+96.88%)
Mutual labels:  hcl, terraform-module
terraform-aws-resource-naming
Terraform module to generate resource name with random_id added as suffix.
Stars: ✭ 18 (-43.75%)
Mutual labels:  hcl, terraform-module
terraform-aws-kms
This terraform module creates a KMS Customer Master Key (CMK) and its alias.
Stars: ✭ 14 (-56.25%)
Mutual labels:  hcl, terraform-module
terraform-aws-apigateway-v2
Terraform module to create an AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
Stars: ✭ 71 (+121.88%)
Mutual labels:  terraform-module
terraform-provider-minio
Terraform provider for managing minio S3 buckets and IAM Users
Stars: ✭ 123 (+284.38%)
Mutual labels:  hcl
terraform-metal-anthos-on-baremetal
Terraform module for quick deployment of baremetal Anthos on Equinix Metal
Stars: ✭ 22 (-31.25%)
Mutual labels:  terraform-module
terraform-github-actions-demo
HashiCorp Terraform Github Actions Demo for Github Satellite 2020.
Stars: ✭ 40 (+25%)
Mutual labels:  hcl
terraform-aws-ecs-web-app
Terraform module that implements a web app on ECS and supports autoscaling, CI/CD, monitoring, ALB integration, and much more.
Stars: ✭ 175 (+446.88%)
Mutual labels:  terraform-module
terraform-aws-sqs
Terraform module which creates SQS resources on AWS 🇺🇦
Stars: ✭ 53 (+65.63%)
Mutual labels:  terraform-module
terraform-aws-ecs-fargate-task-definition
AWS ECS Fargate Task Definition Terraform Module
Stars: ✭ 20 (-37.5%)
Mutual labels:  terraform-module
terraform-aws-config
This module configures AWS Config, a service that enables you to assess, audit, and evaluate the configurations of your AWS resources.
Stars: ✭ 24 (-25%)
Mutual labels:  terraform-module
terraform-vsphere-single-vm
Deploy single vSphere VM with Terraform - template.
Stars: ✭ 21 (-34.37%)
Mutual labels:  hcl
terraform-aws-ecs-fargate-service
AWS ECS Fargate Service Terraform Module
Stars: ✭ 52 (+62.5%)
Mutual labels:  terraform-module
provose
Provose is a new way to manage your Amazon Web Services infrastructure.
Stars: ✭ 27 (-15.62%)
Mutual labels:  terraform-module
terraform-external-module-artifact
Terraform module to fetch any kind of artifacts using curl (binary and text okay)
Stars: ✭ 13 (-59.37%)
Mutual labels:  terraform-module
AutoSpotting
Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances.
Stars: ✭ 2,058 (+6331.25%)
Mutual labels:  terraform-module
terraform-vultr-condor
Kubernetes Deployment Tool for Vultr
Stars: ✭ 60 (+87.5%)
Mutual labels:  terraform-module
terraform-aws-lambda
A Terraform module to create AWS Lambda ressources.
Stars: ✭ 40 (+25%)
Mutual labels:  terraform-module
terraform-tuesdays
Demo files for various Terraform Tuesday Examples
Stars: ✭ 211 (+559.38%)
Mutual labels:  terraform-module

terraform-aws-autoscaling

Terraform Version Release Last Commit Issues Pull Requests License Open Source Love

Description

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

Table of Content

Dependencies

This Terraform module uses another Terraform module, here is the list of Terraform module dependencies:

Getting Started

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
}

Examples

Terraform Version

This module was created on 15/08/2018. The latest stable version of Terraform which this module tested working is Terraform 0.13.7 on 28/09/2021.

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
aws n/a

Modules

Name Source Version
asg_name github.com/traveloka/terraform-aws-resource-naming.git v0.20.0
launch_template_name github.com/traveloka/terraform-aws-resource-naming.git v0.20.0

Resources

Name Type
aws_autoscaling_group.main resource
aws_launch_template.main resource
aws_ami.latest_service_image data source

Inputs

Name Description Type Default Required
application Application type that the ASG's instances will serve string n/a yes
asg_clb_names A list of classic load balancer names to add to the autoscaling group list(string) [] no
asg_default_cooldown Time, in seconds, the minimum interval of two scaling activities string "300" no
asg_desired_capacity The created ASG will have this number of instances at desired string "2" no
asg_enabled_metrics The list of ASG metrics to collect list(string)
[
"GroupMinSize",
"GroupMaxSize",
"GroupDesiredCapacity",
"GroupInServiceInstances",
"GroupPendingInstances",
"GroupStandbyInstances",
"GroupTerminatingInstances",
"GroupTotalInstances"
]
no
asg_health_check_grace_period Time, in seconds, to wait for new instances before checking their health string "300" no
asg_health_check_type Controls how ASG health checking is done string "ELB" no
asg_lb_target_group_arns The created ASG will be attached to this target group list(string) [] no
asg_max_capacity The created ASG will have this number of instances at maximum string "0" no
asg_metrics_granularity The granularity to associate with the metrics to collect string "1Minute" no
asg_min_capacity The created ASG will have this number of instances at minimum string "0" no
asg_placement_group The placement group for the spawned instances string "" no
asg_service_linked_role_arn The ARN of the service-linked role that the ASG will use to call other AWS services string "" no
asg_tags The created ASG will have these tags applied over the default ones (see main.tf) list(map(string)) [] no
asg_termination_policies Specify policies that the auto scaling group should use to terminate its instances list(string)
[
"Default"
]
no
asg_vpc_zone_identifier The created ASG will spawn instances to these subnet IDs list(string) n/a yes
asg_wait_for_capacity_timeout A maximum duration that Terraform should wait for ASG instances to be healthy before timing out string n/a yes
asg_wait_for_elb_capacity Terraform will wait for exactly this number of healthy instances in all attached load balancers on both create and update operations. If left to default, the value is set to asg_min_capacity string "" no
associate_public_ip Whether to associate public IP to the instance string "false" no
cluster_role Primary role/function of the cluster string "app" no
cpu_credits The credit option for CPU usage, can be either 'standard' or 'unlimited' string "unlimited" no
delete_network_interface_on_termination Whether the network interface will be deleted on termination string "true" no
delete_on_termination Whether the volume should be destroyed on instance termination string "true" no
description Free form description of this ASG and its instances string n/a yes
disable_api_termination whether to protect your instance from accidently being terminated from console or api bool false no
ebs_encryption Whether the volume will be encrypted or not string "false" no
ebs_optimized The spawned instances will have EBS optimization if enabled string "false" no
environment The created resources will belong to this infrastructure environment string n/a yes
image_filters The AMI search filters. The most recent AMI that pass this filter will be deployed to the ASG. See https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html
list(object({
name = string,
values = list(string)
})
)
n/a yes
image_owners List of AMI owners to limit search. This becomes required starting terraform-provider-aws v2 (https://www.terraform.io/docs/providers/aws/guides/version-2-upgrade.html#owners-argument-now-required) list(string) n/a yes
instance_profile_name The spawned instances will have this IAM profile string n/a yes
key_name The spawned instances will have this SSH key name string "" no
launch_template_overrides List of nested arguments provides the ability to specify multiple instance types. See https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#override
When using plain launch template, the first element's instance_type will be used as the launch template instance type.
list(map(string))
[
{
"instance_type": "c4.large"
},
{
"instance_type": "t3.medium"
}
]
no
mixed_instances_distribution Specify the distribution of on-demand instances and spot instances. See https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_InstancesDistribution.html map(string)
{
"on_demand_allocation_strategy": "prioritized",
"on_demand_base_capacity": "0",
"on_demand_percentage_above_base_capacity": "100",
"spot_allocation_strategy": "lowest-price",
"spot_instance_pools": "2",
"spot_max_price": ""
}
no
monitoring The spawned instances will have enhanced monitoring if enabled string "true" no
product_domain Abbreviation of the product domain this ASG and its instances belongs to string n/a yes
security_groups The spawned instances will have these security groups list(string) n/a yes
service_name The name of the service string n/a yes
use_mixed_instances_policy Whether to use ASG mixed instances policy or the plain launch template bool true no
user_data The spawned instances will have this user data. Use the rendered value of a terraform's template_cloudinit_config data string " " no
volume_size The size of the volume in gigabytes string "8" no
volume_type The type of volume. Can be standard, gp2, or io1 string "gp2" no

Outputs

Name Description
asg_desired_capacity The desired capacity of the auto scaling group; it may be useful when doing blue/green asg deployment (create a new asg while copying the old's capacity)
asg_name The name of the auto scaling group
launch_template_name The name of the launch template used by the auto scaling group
resource_naming_launch_template The name of the launch template generated by resource-naming module.

Authors

Contributing

This module accepting or open for any contributions from anyone, please see the CONTRIBUTING.md for more detail about how to contribute to this module.

License

This module is under Apache License 2.0 - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].