Skip to main content

Autoscaling Group Basic

πŸ“¦ Overview​

This Terraform module provisions a basic Auto Scaling Group (ASG) in AWS to enable horizontal scalability of stateless compute workloads.

It’s ideal for environments where simple scaling behavior is sufficient and advanced policies or integrations are not yet required.


βœ… Key Features​

  • Launches EC2 instances using a provided AMI and instance type
  • Scales compute resources between min_size, max_size, and desired_capacity
  • Supports resource and environment tagging for visibility and management

πŸ’Ό Use Cases​

  • Base infrastructure for scalable microservices
  • Development or QA environments requiring dynamic instance pools
  • Compute clusters without complex lifecycle policies
  • Environments with manual or schedule-based scaling triggers

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region to deploy the Auto Scaling group
ami_idstringID of the Amazon Machine Image to use for EC2 instances
instance_typestringEC2 instance type (e.g., t3.micro)
subnet_idslistList of subnet IDs for instance placement
min_sizenumberMinimum number of instances in the group
max_sizenumberMaximum number of instances in the group
desired_capacitynumberDesired number of instances to launch
environmentstringTag to specify the deployment environment (e.g., dev, prod)

πŸ“€ Outputs​

NameDescription
autoscaling_group_nameThe name of the created Auto Scaling group
launch_template_idThe ID of the associated launch template (if applicable)
instance_typeThe EC2 instance type used

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Use independently or as part of a larger compute layer

πŸ› οΈ Example Usage​

module "autoscaling_group_basic" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//compute/autoscaling-group-basic?ref=v1.0.0"

region = "us-east-1"
ami_id = "ami-0123456789abcdef0"
instance_type = "t3.micro"
subnet_ids = ["subnet-abc123", "subnet-def456"]
min_size = 1
max_size = 3
desired_capacity = 2
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

For testing:

terraform destroy

or

tofu destroy

For production:

Manually delete the Auto Scaling group and related resources via the AWS Console or CLI to prevent disruption of live services.

πŸ›‘οΈ Notes​

This is a Level 1 compute module intended for foundational ASG setups. For advanced features like lifecycle hooks, CloudWatch alarms, or ALB/NLB integration, use a composed Level 2 module or add orchestration manually.

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.