CareerByteCode
ByteBlogby CareerByteCode

AWS VPC with Terraform: ALB and Auto Scaling

🟢 Beginner

Learn how to build, deploy, test and troubleshoot an AWS Multi-AZ architecture using Terraform, VPC, Application Load Balancer and EC2 Auto Scaling.

AWS VPC with Terraform: ALB and Auto Scaling

✍️ Translate this blog into Hindi, Tamil or Telugu


In this project, I explore AWS VPC with Terraform by building a multi-AZ architecture with public and private subnets, an Application Load Balancer and an EC2 Auto Scaling Group. I also configure health checks, CloudWatch monitoring and remote Terraform state management while testing the infrastructure on AWS.

The story behind the project

What happens when a web application grows beyond what one EC2 instance can comfortably handle?

At the beginning, a single server may be enough. We launch an instance, install a web server, and the application responds. But as more users arrive, new questions appear.

🛍️✨ From the author · ByteStore1:1 DevOps Project & Learning Discussionโ‚น500View offer →

What happens if the instance becomes unhealthy? How do we distribute incoming requests? Should application servers be exposed directly to the internet? How can we increase capacity without manually launching instances every time demand changes?

I wanted to understand how these pieces fit together, not just learn the definitions of VPC, ALB, Auto Scaling and Terraform.

So I built an AWS Multi-AZ architecture using Terraform and followed the infrastructure lifecycle: prepare, plan, provision, verify, test, monitor, troubleshoot and clean up.

Think of the architecture as a small city. The VPC is the boundary around it. Public and private subnets are different areas with different access rules. The Application Load Balancer is the reception desk that directs incoming requests to available application servers. The bastion host is a controlled entrance for administration, while the NAT Gateway provides an outbound route for private resources that need internet access.

This was a real hands-on learning project, and not every test produced the result I initially expected. I had to troubleshoot AWS credentials, check SSH access, investigate target health and distinguish unhealthy-instance replacement from CPU-based scaling. Those experiences are part of the learning process.

The project provisions a VPC across two Availability Zones, public and private subnets, an Internet Gateway, a NAT Gateway, a bastion host, an internet-facing Application Load Balancer, private EC2 application instances, an Auto Scaling Group, CPU target tracking, CloudWatch monitoring and an S3 remote Terraform backend.

Important project status: The deployment was completed and the infrastructure was subsequently destroyed. The screenshots show the original deployment and verification activities. The ALB and EC2 instances are no longer running. The S3 remote state bucket was retained separately.


1. Why Do We Need This Use Case?

Imagine deploying a web application on a single EC2 instance.

Initially, the application may work perfectly. However, as the number of users increases, several problems can occur:

  • The server may experience high CPU utilization.

  • The application may become slow.

  • If the instance fails, the application may become unavailable.

  • Exposing the application server directly to the internet increases its exposure.

  • Manually adding and removing instances becomes difficult to manage.

In a cloud environment, we need an architecture that separates public-facing components from application resources, distributes incoming traffic and can adjust application capacity.

This is where AWS networking, load balancing, Auto Scaling and Infrastructure as Code become useful.

What are we building?

We are building an AWS infrastructure in which:

  1. An internet-facing Application Load Balancer receives HTTP requests.

  2. The ALB forwards requests to healthy application instances.

  3. Application instances run inside private subnets.

  4. A bastion host provides controlled SSH access to private instances.

  5. An Auto Scaling Group maintains the required number of application instances.

  6. A CPU target tracking policy is configured to adjust capacity based on utilization.

  7. CloudWatch provides visibility into CPU utilization and scaling-related metrics.

  8. Terraform provisions and manages the infrastructure.

Instead of creating every resource manually through the AWS Console, we define the infrastructure using Terraform.

2. When Do We Need This Use Case?

This architecture is useful when:

  • An application needs to handle incoming HTTP traffic from users.

  • Application servers should not be directly accessible from the public internet.

  • Traffic needs to be distributed across multiple application instances.

  • Application capacity should be adjusted based on demand.

  • Unhealthy application instances should be replaced automatically.

  • Infrastructure needs to be reproducible and version-controlled.

  • Teams need a consistent approach to provisioning cloud environments.

Real-world example

Consider an online shopping application during a major sale.

During normal hours, two application instances may be sufficient. During a sale, traffic may increase significantly.

An Application Load Balancer distributes incoming requests across healthy instances. An Auto Scaling Group can add instances when its configured scaling conditions are met.

This project demonstrates the infrastructure components needed for that type of architecture.


3. Architecture and Design Decisions

3.1 High-Level Architecture

The infrastructure was deployed in the AWS Oregon region (us-west-2) across two Availability Zones.

High-Level Architecture

The design separates public-facing resources from private application resources.

The ALB receives incoming application traffic. The application instances run in private subnets, and the bastion host provides controlled SSH access for administration.

Architecture diagram:

AWS VPC architecture with Terraform and Auto Scaling

Additional architecture views:

Editable AWS VPC architecture preview

The diagrams represent the logical design. They do not indicate that the resources are currently running.

3.2 Network Design

ComponentConfiguration
AWS Regionus-west-2 (Oregon)
Availability Zonesus-west-2a, us-west-2b
VPC CIDR10.0.0.0/16
Public Subnet 110.0.1.0/24
Public Subnet 210.0.2.0/24
Private Subnet 110.0.11.0/24
Private Subnet 210.0.12.0/24
Internet Gateway1
NAT Gateway1
Elastic IP1

3.3 Public and Private Subnets

Public subnets

Public subnets contain resources that need to be reachable through the internet-facing network path.

We deployed:

  • Application Load Balancer.

  • Bastion EC2 instance.

  • NAT Gateway in the first public subnet.

Private subnets

Private subnets contain application instances that should not be directly accessible from the public internet.

We deployed application EC2 instances managed by the Auto Scaling Group.

The private route tables direct internet-bound traffic through the NAT Gateway.

3.4 How Does Application Traffic Flow?

Let's follow a request from a user to the application.

  1. A user sends an HTTP request to the ALB DNS endpoint.

  2. The Internet Gateway provides the VPC's internet connectivity.

  3. The ALB receives the request on port 80.

  4. The ALB forwards the request to its target group.

  5. The target group routes traffic to healthy application instances.

  6. The NGINX web server on the application instance processes the request.

  7. The response travels back through the ALB to the user.

AWS networking traffic flow

3.5 Security Design

Security groups control communication between the different infrastructure layers.

ResourceInbound rulePurpose
ALB Security GroupHTTP 80 from internetReceive application requests
Application Security GroupHTTP 80 from ALB Security GroupAccept application traffic
Application Security GroupSSH 22 from Bastion Security GroupAllow controlled administration
Bastion Security GroupSSH 22 from administrator /32 CIDRRestrict SSH access

The application instances do not require public IP addresses.

3.6 Compute and Auto Scaling Configuration

ComponentConfiguration
AMIUbuntu 24.04
Instance typet3.micro
Root volume8 GiB gp3
Volume encryptionEnabled
Metadata serviceIMDSv2 required
Auto Scaling minimum2
Auto Scaling desired2
Auto Scaling maximum4
CPU target tracking50%
Instance warmup180 seconds
Load balancer protocolHTTP
Application port80

The Launch Template installs NGINX and stress-ng using EC2 user data.

3.7 Design Decisions and Trade-offs

Every architecture decision has a benefit and a limitation. Understanding both is important when moving from a learning environment to a production environment.

Design decisionWhy it was usedLimitation
Two Availability ZonesDistribute resources across AZsDoes not guarantee application-level resilience by itself
Public ALBProvides a public application entry pointHTTP is not encrypted
Private application instancesReduce direct internet exposureRequire controlled administration access
One shared NAT GatewayReduce lab infrastructure costSingle point of failure and possible cross-AZ data charges
Bastion hostControlled SSH accessRequires secure key and access management
Auto Scaling GroupManages application instance capacityScaling depends on policy and metric behavior
S3 backendCentralized Terraform stateRequires appropriate bucket access and protection

A note about the NAT Gateway: This project uses one NAT Gateway in the first Availability Zone. Private resources in the other Availability Zone also use it for outbound connectivity. This keeps the learning architecture simpler, but introduces a dependency on one NAT Gateway and can result in cross-AZ data transfer charges.

A production environment may use multiple NAT Gateways, HTTPS with ACM certificates, stricter IAM permissions, additional monitoring and more comprehensive application-level health checks.

3.8 Terraform Configuration Files

The project contains 17 Terraform configuration files.

FileResponsibility
versions.tfTerraform and provider version requirements
provider.tfAWS provider configuration
backend.tfS3 remote state backend
variables.tfInput variables
outputs.tfTerraform outputs
vpc.tfVPC creation
subnets.tfPublic and private subnets
internet-gateway.tfInternet Gateway
nat-gateway.tfNAT Gateway and Elastic IP
route-tables.tfPublic and private routing
security-groups.tfSecurity group rules
bastion.tfBastion EC2 instance
iam.tfIAM role and instance profile
launch-template.tfApplication instance configuration
alb.tfApplication Load Balancer and target group
autoscaling.tfAuto Scaling Group and scaling policy
cloudwatch.tfCloudWatch dashboard

The next sections cover the prerequisites and the original implementation steps.


4. Prerequisites

Before building the AWS Multi-AZ architecture with Terraform, we need an AWS account, the required permissions and a few tools installed in our development environment.

This section covers the IAM setup, required tools and AWS CLI configuration used in this project.

4.1 IAM Setup โ€“ User, Group, Permissions and Access Key

Terraform needs permission to communicate with AWS and create infrastructure resources. For this project, I created a dedicated IAM user group named:

VPC-ALB-ASG-Terraform-Lab

The IAM setup involved the following steps:

  1. Created an IAM user group named VPC-ALB-ASG-Terraform-Lab.

  2. Attached the required AWS service permissions to the group.

  3. Created a dedicated IAM user and added it to the group.

  4. Generated an access key for AWS CLI authentication.

  5. Configured a separate AWS CLI profile for this project.

Project setup overview

The following diagram shows the AWS account and Terraform project setup:

AWS and Terraform project setup

4.2 Required Tools

The following tools were used to build and manage the infrastructure.

ToolPurpose
AWS AccountCreate and manage AWS resources
AWS CLIInteract with AWS services from the terminal
TerraformDefine and provision infrastructure as code
GitTrack changes to project files
GitHubStore and share the project source code
WSL UbuntuProvide a Linux development environment
SSH ClientConnect to EC2 instances for administration

4.3 Verify Terraform Installation

What are we doing?

Before writing Terraform configuration files, we need to confirm that Terraform is installed and available in the terminal.

Command:

terraform version

Expected result:

Terraform displays the installed version.

The version used in this project was:

Terraform v1.17.2

4.4 Verify AWS CLI Installation

What are we doing?

The AWS CLI allows us to interact with AWS services directly from our terminal. We use it to authenticate, verify our AWS account and perform other AWS operations.

Command:

aws --version

Expected result:

The terminal displays the installed AWS CLI version.

4.5 Verify Git Installation

What are we doing?

Git helps us track changes to our Terraform configuration files and manage the project source code.

Command:

git --version

Expected result:

The terminal displays the installed Git version.

4.6 AWS Permissions and IAM Role Concepts

IAM role versus instance profile flow

For this learning lab, we used a dedicated IAM user and the IAM group:

VPC-ALB-ASG-Terraform-Lab

The group was configured with broad permissions across the AWS services required for the project, including:

  • EC2

  • S3

  • VPC

  • Auto Scaling

  • CloudWatch

  • Elastic Load Balancing

  • IAM

These permissions allowed Terraform and the AWS CLI to work with the services involved in the deployment.

Understanding IAM roles and instance profiles

An IAM user and an IAM role serve different purposes. An IAM user can authenticate through access keys, while an IAM role provides temporary credentials to an AWS service or an application that assumes the role.

An EC2 instance profile is the container through which an IAM role is associated with an EC2 instance.

The following diagrams explain these concepts and how they work together:

IAM roles and instance profiles explained

Security consideration

The learning environment used broad service-level permissions to complete the project. However, attaching full-access policies across multiple AWS services is not recommended for production environments.

For real-world deployments, follow the principle of least privilege: grant only the permissions required to perform specific tasks on the necessary resources.

Never upload AWS access keys or secret keys to GitHub, and make sure credentials are not visible in screenshots.

4.7 Configure a Separate AWS CLI Profile

Instead of using the default AWS CLI profile, I configured a separate profile for this Terraform project.

This helps keep the project credentials separate from other AWS environments.

Command:

aws configure --profile vpc-alb-asg-lab

The AWS CLI prompts for four values:

  • AWS Access Key ID

  • AWS Secret Access Key

  • Default region name

  • Default output format

Enter your own credentials locally. For this project, the AWS region was set to us-west-2 (US West โ€“ Oregon).

Set the project environment variables

To use this profile and region in the current terminal session, run:

export AWS_PROFILE=vpc-alb-asg-lab
export AWS_DEFAULT_REGION=us-west-2

These environment variables tell AWS CLI and compatible tools which profile and region to use by default in the current shell session.

Verify the authenticated AWS identity

Before creating any infrastructure, verify that the CLI is connected to the expected AWS account.

Command:

aws sts get-caller-identity \
  --profile vpc-alb-asg-lab \
  --region us-west-2

Why do we verify this?

This command calls AWS Security Token Service (STS) and returns information about the identity being used, including the AWS account ID and the authenticated user or role ARN.

It helps confirm that we are working with the intended AWS account before provisioning resources.

Expected result:

The output should contain details similar to:

{
    "UserId": "AIDAEXAMPLEUSERID",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/example-user"
}

The values above are illustrative. Your actual output will contain your own AWS account and IAM identity details.

Prerequisite verification complete.

We now have the required tools, IAM access and AWS CLI profile configured. We can move on to preparing the Terraform project and defining the AWS infrastructure.


5. Advantages and Limitations

Advantages

  1. Infrastructure as Code: Infrastructure is defined and version-controlled using Terraform.

  2. Network isolation: Public-facing and private application components are separated.

  3. Controlled access: Security groups restrict communication between infrastructure layers.

  4. Load balancing: Incoming HTTP requests are distributed across healthy targets.

  5. Auto Scaling: The ASG can adjust application capacity according to its configured scaling policy.

  6. Health-based replacement: Unhealthy instances can be replaced automatically by the ASG.

  7. Monitoring: CloudWatch provides visibility into CPU utilization and scaling-related metrics.

  8. Remote state: S3 provides centralized Terraform state storage and native locking.

Limitations

  1. Single NAT Gateway: The NAT Gateway is a potential single point of failure and can introduce cross-AZ data charges.

  2. HTTP only: The lab uses HTTP port 80 and does not implement HTTPS.

  3. Bastion dependency: SSH administration depends on the availability and security of the bastion host.

  4. Lab IAM permissions: The IAM group used broad permissions rather than a production least-privilege policy.

  5. Basic application: NGINX is used to demonstrate infrastructure behavior, not a complete production application.

  6. Scaling validation: The CPU-based policy was configured and load was generated, but a CPU-triggered scale-out or scale-in event was not confirmed in the recorded activity history.

  7. Cost: NAT Gateway, EC2, ALB, EBS and other AWS resources can generate charges.



6. Step-by-Step Implementation

This section walks through the implementation of the AWS Multi-AZ architecture using Terraform. We begin by preparing the environment and configuring access, then initialize Terraform, provision the infrastructure, and verify how the deployed components work together.

Each phase explains what we are doing, why it is needed, the commands or console steps involved, and how we verify the result.

Phase 1: Verify Tools and Prepare the Environment

What are we doing?

We start by checking Terraform, AWS CLI and Git. We also prepare the AWS CLI profile and verify the AWS account identity.

Why are we doing it?

Before creating AWS resources, we need to make sure the required tools are available and that our terminal is authenticated against the correct AWS account.

Commands โ€“ Verify installed tools

terraform version
aws --version
git --version

Configure the AWS CLI profile

aws configure --profile vpc-alb-asg-lab

Set the environment variables

export AWS_PROFILE=vpc-alb-asg-lab
export AWS_DEFAULT_REGION=us-west-2

These variables tell AWS CLI and compatible tools which profile and region to use in the current terminal session.

Verify the AWS identity

aws sts get-caller-identity \
  --profile vpc-alb-asg-lab \
  --region us-west-2

Check available Availability Zones

aws ec2 describe-availability-zones \
  --profile vpc-alb-asg-lab \
  --region us-west-2 \
  --query 'AvailabilityZones[*].ZoneName' \
  --output table

This command lists the Availability Zones available in the selected AWS region.

Verification

We confirmed that the required tools were installed, the AWS CLI could authenticate, and the Availability Zones were available before proceeding.

Verify Terraform and AWS CLI


Phase 2: Create IAM Group and Dedicated IAM User

What are we doing?

We create a dedicated IAM group and IAM user for this Terraform learning project.

Why are we doing it?

Using a separate IAM identity helps keep project access separate from other AWS activities. It also makes it easier to identify which credentials are being used for the lab.

AWS Console steps

  1. Open the AWS Management Console and navigate to IAM.

  2. Create a group named VPC-ALB-ASG-Terraform-Lab.

  3. Attach the permissions required for the learning lab.

  4. Create a dedicated IAM user.

  5. Add the user to the newly created group.

  6. Create an access key for local AWS CLI authentication.

  7. Select the Command Line Interface (CLI) use case.

  8. Configure the AWS CLI profile on your local machine.

Important security note: Keep your access key and secret access key private. Never commit credentials to GitHub or publish screenshots that expose them.

Verification

We checked that the IAM group and user were created and that the configured AWS CLI profile could authenticate successfully.

Create IAM group

Attach IAM permissions

IAM group created

Select AWS service permissionsCreate IAM users

Create a separate IAM userSet IAM user permissions

Review IAM user configurationIAM user created

Create access key

Select CLI use case

Access key description

Access key created

AWS secret access key display

Configure WSL Ubuntu

AWS CLI configuration


Phase 3: Prepare the Terraform Project and S3 Backend

What are we doing?

We prepare the Terraform project directory, review the configuration files and configure an S3 remote backend to store Terraform state.

Why are we doing it?

Terraform state keeps track of the resources managed by Terraform and connects our configuration to the actual infrastructure in AWS.

Storing the state remotely in Amazon S3 provides centralized storage and supports safer state management.

Prepare the project directory

Move into the project directory:

cd ~/projects/aws-vpc-alb-asg-terraform

Check the current location:

pwd

List the project files:

ls -la

Check available Availability Zones

aws ec2 describe-availability-zones \
  --region us-west-2 \
  --query 'AvailabilityZones[*].ZoneName' \
  --output table

Configure the S3 backend

The backend configuration specifies the S3 bucket, state file location and AWS region.

The configuration follows this pattern:

terraform {
  backend "s3" {
    bucket       = "YOUR_S3_BUCKET_NAME"
    key          = "aws-vpc-alb-asg-terraform/terraform.tfstate"
    region       = "us-west-2"
    encrypt      = true
    use_lockfile = true
  }
}

Replace YOUR_S3_BUCKET_NAME with the bucket configured in your own AWS environment.

The bucket used in this project was:

vpc-alb-asg-tfstate-1795857797-26538

Why use use_lockfile = true?

Terraform uses this setting to enable native S3 state locking. It helps prevent concurrent Terraform operations from modifying the same state simultaneously.

For this project, we used S3-based state locking and did not use DynamoDB for state locking.

Configure .gitignore

Terraform generates local files during initialization and execution. Some files may contain sensitive information or should not be tracked in Git.

The project excludes files such as:

.terraform/
*.tfstate
*.tfstate.*
*.tfvars
*.pem
*.csv
crash.log
terraform.tfplan

Review the actual .gitignore file in the repository before using it in another environment.

Inspect the Terraform configuration

cat backend.tf
cat versions.tf
cat provider.tf

These files help us review the backend, Terraform version requirements and AWS provider configuration.

Verification

We reviewed the S3 backend settings, Terraform version requirements, provider configuration and Git exclusions.

Check Availability Zones

Review Git ignore configuration

Create and verify S3 bucket

Create and verify S3 bucket

Secure the S3 bucket

Inspect backend configuration

Inspect Terraform version requirements

Inspect AWS provider configuration


Phase 4: Configure SSH Access and Terraform Variables

What are we doing?

We prepare the EC2 key pair, identify the administrator's public IP address and configure the Terraform input variables needed for the deployment.

Why are we doing it?

The bastion host provides an administrative entry point for accessing private EC2 instances. SSH access should be restricted rather than exposed to every IP address on the internet.

We use a dedicated EC2 key pair and restrict inbound SSH access to the administrator's public IP address.

Create an EC2 key pair

Open the EC2 service in the AWS Console and create a dedicated key pair for the project.

Download and store the private key securely on your local machine. Do not commit it to GitHub.

Identify the administrator's public IP

Use an approved IP-checking service or your preferred network method to identify your current public IP address.

The Terraform configuration expects the administrator CIDR in this format:

YOUR_PUBLIC_IP/32

A /32 CIDR represents one IPv4 address.

Configure terraform.tfvars

The project uses a variable file to provide environment-specific values.

For example:

aws_region       = "us-west-2"
key_pair         = "YOUR_EC2_KEY_PAIR_NAME"
allowed_ssh_cidr = "YOUR_PUBLIC_IP/32"

Use the exact variable names defined in the repository's variables.tf file. The example values above must be replaced with the values for your environment.

Do not commit terraform.tfvars if it contains sensitive or environment-specific information.

Format the Terraform files

terraform fmt -recursive

Terraform formats the configuration files consistently.

Verification

We checked that the EC2 key pair was available, the SSH CIDR was restricted to the administrator's IP address and the Terraform configuration files were formatted.

Create EC2 key pair

Detect public IP

Create Terraform variables file

Verify SSH CIDR

Terraform formatting

Verify Terraform configuration files


Phase 5: Initialize, Validate and Plan Terraform

What are we doing?

We initialize Terraform, validate the configuration, check the provider dependencies and generate an execution plan.

Why are we doing it?

Terraform initialization downloads the required provider plugins and prepares the configured backend.

Validation checks the structure and syntax of the configuration. The execution plan shows what Terraform intends to create, modify or destroy before those changes are made in AWS.

Initialize Terraform

terraform init

Validate the configuration

terraform validate

Expected result:

Success! The configuration is valid.

Check Terraform formatting

terraform fmt -check -recursive

Review the provider lock file

ls -l .terraform.lock.hcl

The lock file records the selected provider versions and their checksums.

Review IAM permissions

Before provisioning, confirm that the IAM identity has the permissions required by the Terraform configuration, including permissions for the AWS resources and data sources used in the project.

Generate the Terraform plan

The original deployment used:

terraform plan -out=tfplan

This generates a saved execution plan.

To review the plan:

terraform show -no-color tfplan

To inspect the final resource summary:

terraform show -no-color tfplan | tail -n 30

Important: The saved plan documents the original deployment. It is not a reusable deployment instruction. If you recreate the lab later, generate and review a fresh plan before applying it.

Verification

During the original deployment, Terraform successfully validated the configuration and generated a plan showing:

Plan: 28 to add, 0 to change, 0 to destroy.

Terraform initialization

Terraform validation

Provider lock file

IAM permissions and policy verification

Terraform plan

Review complete resource list

Review resource addresses and plan summary


Phase 6: Deploy and Verify AWS Infrastructure

What are we doing?

We apply the reviewed Terraform execution plan to create the AWS infrastructure.

Why are we doing it?

The terraform apply command creates the actual AWS resources defined in our configuration.

This is where the infrastructure design becomes a working deployment.

Historical deployment command

The original deployment used:

terraform apply tfplan

Cost warning: This command creates billable AWS resources. The infrastructure described here was deployed and subsequently destroyed. Run it only if you intentionally want to recreate the lab and have reviewed the potential AWS charges.

During the original deployment, Terraform reported:

Apply complete! Resources: 28 added, 0 changed, 0 destroyed.

Review Terraform outputs

terraform output

Outputs can provide useful information such as the ALB DNS name and other deployment details.

List Terraform-managed resources

terraform state list

This displays the resource addresses currently tracked in Terraform state.

Verify the application through the ALB

During the original deployment, we used the ALB DNS output to access the application.

curl -I http://YOUR_ALB_DNS_NAME

Replace YOUR_ALB_DNS_NAME with the actual ALB DNS name from your deployment.

A successful response was:

HTTP/1.1 200 OK

The original ALB endpoint was temporary and is no longer active.

Verification

During the original deployment, we confirmed that Terraform created 28 resources and that the application returned an HTTP 200 response through the Application Load Balancer.

Historical Terraform apply

Verify application through load balancerVerify target group healthVerify Auto Scaling GroupVerify load balancingVerify CPU target tracking policyCheck IAM permissionsCheck CPU utilization before scaling test


Phase 7: Access Private EC2 Instances and Generate CPU Load

What are we doing?

We connect to the bastion host and use it to access the private application instances. We also inspect the instances and generate controlled CPU load as part of the monitoring exercise.

Why are we doing it?

The application instances are deployed in private subnets and do not have public IP addresses.

The bastion host provides a controlled administrative path to reach those instances.

Generating CPU load helps us observe instance metrics and understand how CloudWatch monitoring and Auto Scaling policies behave.

Start the SSH agent

On the local machine, run:

eval "$(ssh-agent -s)"

This starts the SSH agent for the current session.

Add the private key

ssh-add /path/to/YOUR_PRIVATE_KEY.pem

Replace the path with the actual location of your EC2 private key.

Connect to the bastion host

ssh -A ubuntu@BASTION_PUBLIC_IP

Replace BASTION_PUBLIC_IP with the public IP address of the bastion host.

The -A option enables SSH agent forwarding, allowing the SSH agent to be used for the next connection.

Connect to a private EC2 instance

From the bastion host:

ssh ubuntu@PRIVATE_INSTANCE_IP

Replace PRIVATE_INSTANCE_IP with the private IP address of the application instance.

Repeat the connection process for the second private instance.

Check the operating system

cat /etc/os-release

This displays the operating system details.

Check available CPU resources

nproc

This displays the number of available processing units.

To monitor CPU and process activity:

top

Verify stress-ng installation

stress-ng --version

This checks whether the CPU stress-testing utility is available.

Generate controlled CPU load

The recorded lab used:

stress-ng --cpu 1 --cpu-load 70 --timeout 5m

This starts one CPU worker at a target load of 70% for five minutes.

Run this test only when intentionally recreating the lab and monitoring the environment.

Important: CPU load and Auto Scaling are not the same thing

Generating CPU load does not automatically prove that an Auto Scaling Group has launched another instance.

The target tracking policy uses CloudWatch metrics and its configured target value. Actual scaling also depends on metric evaluation, cooldown or warm-up behavior and available capacity.

To confirm a scaling event, inspect the CloudWatch metrics and Auto Scaling activity history.

Verification

We accessed the private instances through the bastion host, inspected their operating systems and CPU resources, verified the stress-testing utility and generated controlled CPU load.

Add private key to SSH agent

Connect to bastion host

Check stress-ng installation

Check second private instance

Check CPU resources

Connect to first private instance

Start controlled CPU load on first instance

Start CPU load on second instance

Monitor Auto ScalingCheck Auto Scaling activityVerify current instancesVerify ALB target healthTest ALB with replacement instances


7. Verifying the AWS Infrastructure

After the original Terraform deployment, I used the AWS Console to cross-check the resources created by Terraform.

Why do this when Terraform has already reported a successful deployment?

Because a successful terraform apply tells us that Terraform completed the requested operations. It does not, by itself, prove that the application is reachable, that the target group is healthy or that every part of the architecture behaves as expected.

I inspected the following resources.

7.1 VPC and Networking

The networking verification included:

  • VPC CIDR.

  • Public and private subnets.

  • Internet Gateway.

  • NAT Gateway.

  • Route tables.

  • Security groups.

  • Network ACL.

VPC verification

Subnet verification

Route table verification

Internet Gateway verification

NAT Gateway verification

Security group verification

Network ACL verification

EC2 key pair verification

7.2 EC2 Instances

We checked the EC2 instances deployed in the Oregon region.

EC2 instances

7.3 Target Groups and Load Balancers

We inspected the target group and load balancer configuration.

Target group

Load balancer

Historical ALB DNS URL

The DNS screenshot is historical evidence from the deployment. The endpoint is no longer active.

7.4 S3 Remote State

We also verified the S3 bucket and the Terraform state object.

S3 bucket

Terraform state object in S3

The S3 bucket was retained after infrastructure cleanup. We will return to this when discussing the cleanup process.


8. Testing the Application Load Balancer

The next step was to check whether the ALB could receive requests and forward them to the application instances.

The test focused on three things:

  • Whether the ALB received HTTP requests.

  • Whether the target group contained healthy application instances.

  • Whether both application instances could serve traffic.

8.1 Test the ALB Response

During the original deployment, we accessed the ALB using its DNS endpoint.

The following command checks the HTTP response headers:

curl -I http://YOUR_ALB_DNS_NAME

A successful response from the application was:

HTTP/1.1 200 OK

8.2 Send Repeated Requests

We also sent multiple requests to observe which application instances served them.

for i in {1..10}; do
  curl -s http://YOUR_ALB_DNS_NAME
  echo
done

8.3 What Did We Observe?

The repeated requests were served by two application instances.

Application instanceRequests served
ip-10-0-12-1876
ip-10-0-11-1674
Total10

This confirmed that both application instances served requests through the ALB.

However, it does not prove strict round-robin behavior. Request distribution can vary depending on load-balancing behavior and connection handling.

Verify target group health

Verify load balancing

Test ALB with replacement instances


9. Understanding Auto Scaling and CPU Load Testing

This was an important part of the project because I wanted to understand how an Auto Scaling Group behaves when an application instance becomes unhealthy and when CPU utilization increases.

There are two different behaviors to understand.

9.1 Health-Based Replacement vs Metric-Based Scaling

Health-based replacement

When an instance is considered unhealthy, the Auto Scaling Group can terminate or remove it and launch a replacement to maintain the required capacity.

Metric-based scaling

A scaling policy can increase or decrease the number of instances based on a configured metric, such as average CPU utilization.

These are different operations. An instance being replaced does not automatically mean that CPU-based scaling occurred.

9.2 Auto Scaling Configuration

The original configuration used:

SettingValue
Minimum capacity2
Desired capacity2
Maximum capacity4
CPU target50%
Instance warmup180 seconds

9.3 Generate CPU Load

We used stress-ng to generate controlled CPU load on the application instances.

The command used during the lab was:

stress-ng --cpu 1 --cpu-load 70 --timeout 5m

This creates CPU load for five minutes using one CPU worker.

Generating CPU load is only the beginning of the test. We must also inspect CloudWatch metrics and the Auto Scaling activity history to determine whether the scaling policy actually changed the capacity.

9.4 What Did We Observe?

The Auto Scaling activity history showed:

  • The initial desired capacity changed from 0 to 2.

  • Two application instances were launched.

  • One instance was taken out of service because of an ELB system health check failure.

  • The Auto Scaling Group launched a replacement instance.

  • The recorded activities completed successfully.

The important distinction is that the replacement instance launch was health-based replacement. It was not evidence of CPU-based scaling.

9.5 What Did This Test Teach Me?

Configuring a CPU target tracking policy does not guarantee that a scale-out event will happen during every test.

To confirm CPU-based scaling, we need to check:

  1. The CPU metric over the relevant evaluation period.

  2. The target tracking alarms.

  3. The Auto Scaling activity history.

  4. Scaling cooldown and instance warmup behavior.

  5. Whether the desired capacity actually changed.

Observed result: The project successfully demonstrated Auto Scaling Group management and unhealthy instance replacement. A CPU-triggered scale-out or scale-in event was not confirmed in the recorded activity history.

I consider this an important finding because it is better to report what the monitoring data actually showed than to claim that a test succeeded simply because a scaling policy was configured.

Monitor Auto Scaling

Review Auto Scaling activity

Verify current instancesVerify ALB target health


10. Monitoring with CloudWatch

After checking the Auto Scaling behavior, we inspected the CloudWatch dashboard and the alarms associated with the target tracking policy.

CloudWatch is important because it gives us visibility into resource metrics over time. Without metric history, it is difficult to understand why a scaling policy did or did not change capacity.

10.1 What Did We Monitor?

We used Amazon CloudWatch to inspect:

  • Auto Scaling Group average CPU utilization.

  • Target tracking alarms.

  • CPU metric behavior over the selected time range.

The Terraform configuration created a CloudWatch dashboard for the Auto Scaling Group average CPU metric.

We also reviewed the target tracking alarms managed by the Auto Scaling policy.

10.2 What Did We Observe?

During the recorded inspection:

  • The ASG average CPU graph showed a peak of approximately 4.32% in the selected six-hour period.

  • The target tracking high-side alarm was in the OK state at the time of inspection.

  • The low-side alarm was in the In alarm state at the time of inspection.

These alarm states were observations at that particular time. They do not prove that a CPU scaling event occurred during the earlier stress test.

Target tracking uses managed alarm behavior and dynamic thresholds. We should not assume that the target value of 50% is the exact threshold of every underlying alarm.

10.3 Why Is This Important?

The configured target value, the observed CPU metric and the Auto Scaling activity history must be considered together.

A policy may be configured correctly, but the recorded metric may not have reached the conditions required for a scaling action.

That is why monitoring is part of verification, not just an additional dashboard to look at after deployment.

CloudWatch dashboard

CloudWatch alarmsVerify high CPU target tracking alarmFind the target tracking alarm

Auto Scaling Groups

Auto Scaling Group CLI and Console verification

CPU graph with custom time range


11. Troubleshooting and Lessons Learned

The project did not consist only of creating resources. I also had to investigate issues during configuration, deployment and verification.

Some issues came from credentials and permissions. Others were related to application health and understanding the behavior of Auto Scaling.

The following table summarizes the important observations.

AreaObservation or issueLearning
AWS credentialsInitial Terraform request returned InvalidClientTokenIdVerify the active AWS profile and credentials before running Terraform
Terraform configurationValidation identified unsupported target tracking argumentsCheck provider resource documentation and supported arguments
IAM permissionsSome AWS CLI commands returned AccessDeniedThe calling IAM identity needs permission for the requested API action
SSM inspectionCLI inspection failed due to missing ssm:DescribeInstanceInformation permissionA caller permission failure does not prove the instance-side SSM configuration is broken
CloudTrailEvent lookup failed due to missing cloudtrail:LookupEvents permissionAccessDenied does not prove that no CloudTrail events exist
Target groupAn application instance failed an ELB system health checkVerify application availability, health check settings and target status
Auto ScalingAn unhealthy instance was replacedHealth-based replacement is separate from metric-based scaling
CPU testingCPU load was generated, but CPU-triggered scaling was not confirmedVerify metrics and activity history instead of assuming scaling occurred
Terraform stateState was stored remotely in S3Secure remote state and use locking for coordinated operations

11.1 Terraform Validation

During the configuration process, Terraform validation helped identify configuration issues.

The command used was:

terraform validate

This checks whether the Terraform configuration is structurally valid.

It does not prove that AWS permissions, network connectivity or application behavior are correct.

11.2 Verify the AWS Identity

When AWS API calls fail, the first thing to check is the identity being used.

aws sts get-caller-identity \
  --profile vpc-alb-asg-lab \
  --region us-west-2

This helps confirm the AWS account and identity associated with the request.

Also verify the intended AWS profile and region before retrying a command.

11.3 Investigate Target Group Health

When an application instance becomes unhealthy, check the following:

  • Target group's health status.

  • Health check path and port.

  • NGINX service status.

  • Application security group rules.

  • Network connectivity.

  • Instance system status.

For an intentionally recreated lab, the application service can be checked using:

sudo systemctl status nginx

The important point is to investigate why the health check failed instead of assuming that the instance itself is unavailable.

11.4 Inspect Terraform State

Terraform state helps us understand which resources Terraform currently manages.

To list the resources:

terraform state list

To inspect outputs:

terraform output

To inspect the S3 backend, use the AWS Console or an authorized AWS CLI identity.

11.5 The Most Important Lesson

One of the most important lessons from this project is:

A successful deployment command does not automatically prove that the architecture is working correctly.

We must verify the network, security rules, application response, target health, Auto Scaling activity, monitoring metrics and Terraform state.

Troubleshooting is not separate from implementation. It is part of understanding how the infrastructure behaves.


12. Infrastructure Cleanup

Once testing and verification were complete, the next step was to clean up the AWS infrastructure.

Why is cleanup important?

AWS resources can continue to incur charges even after we finish testing.

Examples include:

  • NAT Gateway.

  • Elastic IP.

  • Application Load Balancer.

  • EC2 instances.

  • EBS volumes.

  • Other provisioned services.

A learning environment should not be left running unnecessarily.

12.1 Review Terraform-Managed Resources

Before destroying resources, review what Terraform manages.

terraform state list

This helps identify the resources associated with the current Terraform state.

12.2 Review the Destroy Plan

The original cleanup workflow included:

terraform plan -destroy

This creates a plan showing the resources Terraform intends to destroy.

Review the plan carefully before proceeding.

12.3 Destroy the Infrastructure

The original cleanup used:

terraform destroy

Important: The infrastructure has already been destroyed. This command is included to document the original cleanup process. Do not run it unless you intentionally recreate the environment and understand which resources Terraform currently manages.

12.4 Verify Cleanup

After the original cleanup, we checked the Terraform state:

terraform state list

The state list was empty.

The AWS Console was also inspected to verify that the Auto Scaling Group and VPC infrastructure had been removed.

12.5 Why Was the S3 Backend Retained?

The S3 remote state bucket was retained separately after the infrastructure cleanup.

The bucket used by the project was:

vpc-alb-asg-tfstate-1795857797-26538

The state key was:

aws-vpc-alb-asg-terraform/terraform.tfstate

The S3 bucket is separate from the application infrastructure. It was not removed by the completed Terraform cleanup.

If the bucket is no longer required, review its contents, versions, access controls and dependencies before deleting it. Do not remove it while another Terraform configuration still depends on it.

Terraform resources managed

Review destroy planDestroy infrastructure and verify Terraform stateVerify Auto Scaling Group and VPC removalVerify retained S3 bucketVerify retained S3 state object


13. Conclusion

This project gave me practical experience building a multi-AZ AWS environment using Terraform.

I worked through VPC networking, public and private subnets, route tables, Internet Gateway, NAT Gateway, security groups, bastion access, an Application Load Balancer, private EC2 instances, an Auto Scaling Group, CloudWatch and S3 remote state.

The most useful learning came from checking what actually happened rather than assuming that every configured feature had been demonstrated.

The ALB served requests from both application instances. The Auto Scaling Group replaced an unhealthy instance. However, the recorded activity history did not confirm a CPU-triggered scale-out or scale-in event.

That distinction changed how I read the results: configuration tells us what the system is intended to do; metrics, health checks and activity history tell us what it actually did.

The project followed the complete infrastructure lifecycle:

Plan โ†’ Provision โ†’ Verify โ†’ Test โ†’ Monitor โ†’ Troubleshoot โ†’ Clean Up

The infrastructure has now been destroyed, and the S3 backend was retained separately.

For me, the main takeaway is that learning cloud infrastructure is not just about provisioning resources. It is about understanding why each component is needed, how the components communicate, how to verify their behavior and how to investigate problems when the result is different from what we expected.



14. Learning Review โ€“ Questions and Answers

Use these questions and answers to revise the AWS networking, load balancing, Auto Scaling, monitoring, Terraform and security concepts covered in this project.

Networking

1. Why do we place application instances in private subnets instead of exposing them directly to the internet?

Application instances are placed in private subnets to reduce their direct exposure to the internet.

In this architecture, users send requests to the internet-facing Application Load Balancer (ALB). The ALB forwards requests to the private application instances through the target group.

This allows application servers to receive application traffic without requiring public IP addresses or direct public internet access.

2. What route-table entry makes a subnet public?

A subnet is considered public when its associated route table contains a route to an Internet Gateway.

For example:

Destination: 0.0.0.0/0
Target:      Internet Gateway (igw-xxxxxxxx)

The Internet Gateway provides the route to and from the internet. The subnet also needs appropriately configured resources, such as public IP addressing and security group rules, for instances to be reachable from the internet.

3. Why does a private subnet use a NAT Gateway for outbound internet access?

A NAT Gateway allows resources in a private subnet to initiate outbound connections to the internet without allowing unsolicited inbound internet connections to those private instances.

For example, a private EC2 instance may need to download operating system updates or install software packages.

The private subnet's route table sends internet-bound traffic to the NAT Gateway in a public subnet.

outbound internet traffic flow from a private EC2 instance

In this project, one NAT Gateway was used across two Availability Zones. This is a cost-saving design for a learning lab, but it introduces a single point of failure and possible cross-AZ data transfer costs.

4. What is the purpose of the bastion host, and how was SSH access restricted in this lab?

A bastion host is a controlled entry point used by administrators to access instances in private subnets.

In this project, the bastion host was deployed in a public subnet. SSH access was restricted using the administrator's public IP address with a /32 CIDR.

The administrator first connected to the bastion host and then connected to the private EC2 instances using their private IP addresses.

This avoids exposing SSH access on the application instances directly to the internet.

Load Balancing and Health Checks

5. What is the difference between an Application Load Balancer and a target group?

An Application Load Balancer (ALB) receives incoming application traffic and routes it according to its listener rules.

A target group is a collection of registered targets, such as EC2 instances, that receive traffic from the load balancer.

In this project:

  • The ALB receives HTTP requests on port 80.

  • The listener forwards matching requests to the target group.

  • The target group contains the application EC2 instances.

Think of the ALB as a reception desk and the target group as the list of application servers available to receive requests.

6. How does a target group's health check affect traffic routing?

A target group's health check periodically checks whether registered targets are responding as expected.

For example, an HTTP health check can send requests to a configured application path and evaluate the response.

  • Healthy targets can receive traffic.

  • Unhealthy targets are generally removed from normal traffic routing until they become healthy again.

In this project, target health was checked to verify that the application instances were available to receive requests.

7. The ALB returned responses from two application instances. What does that prove, and what does it not prove about the exact request distribution?

During the project verification, the ALB returned responses from two application instances:

  • ip-10-0-12-187 received 6 requests.

  • ip-10-0-11-167 received 4 requests.

This confirms that both application instances successfully served requests through the ALB during the test.

However, it does not prove strict round-robin distribution or an equal split of traffic. Load distribution depends on the ALB routing behavior, target health, connection handling and other factors.

Auto Scaling and Monitoring

8. What information is defined in a Launch Template, and what does the Auto Scaling Group manage?

A Launch Template defines the configuration used to launch EC2 instances.

It can include:

  • Amazon Machine Image (AMI)

  • Instance type

  • SSH key pair

  • Security groups

  • Storage configuration

  • IAM instance profile

  • User data

The Auto Scaling Group uses the Launch Template to launch and manage EC2 instances.

In this project, the Auto Scaling Group was configured with:

  • Minimum capacity: 2

  • Desired capacity: 2

  • Maximum capacity: 4

It maintains the desired instance capacity and can add or remove instances based on configured scaling policies and replace unhealthy instances.

9. How is health-based instance replacement different from CPU target tracking?

These are two different Auto Scaling mechanisms.

Health-based instance replacement:

When an instance is reported unhealthy, the Auto Scaling Group can terminate and replace it to maintain the required capacity.

When Elastic Load Balancing health checks are intended to influence instance replacement, the Auto Scaling Group must be configured to use ELB health checks, for example, through:

health_check_type = "ELB"

The Auto Scaling Group can then use the load balancer's health information when determining whether an instance is healthy.

In this project, an unhealthy instance was replaced following an Elastic Load Balancing health check failure.

CPU target tracking:

Target tracking adjusts the number of EC2 instances based on a metric such as average CPU utilization.

For example, if the target tracking policy is configured for 50% average CPU utilization, Auto Scaling attempts to maintain the metric near that target by adjusting capacity when required.

An unhealthy-instance replacement is not evidence of CPU-based scale-out.

10. What evidence would you inspect before claiming that CPU-based scale-out occurred?

We should inspect multiple sources of evidence instead of relying on a single observation.

Useful checks include:

  1. CloudWatch CPU utilization metrics over the relevant evaluation period.

  2. The Auto Scaling Group's activity history.

  3. Scaling policy details and CloudWatch alarms.

  4. EC2 instance launch events and timestamps.

  5. Changes in the Auto Scaling Group's desired and actual capacity.

A CPU-based scale-out claim should be supported by evidence showing that the scaling policy responded to the CPU metric and increased capacity.

In this project, an unhealthy-instance replacement was observed. The recorded CPU metrics did not establish a confirmed CPU-triggered scale-out event.

11. Why should CloudWatch metrics be reviewed over the relevant evaluation period rather than relying on a single snapshot?

A single CPU reading shows utilization at one moment. It does not explain how the application behaved over time.

Auto Scaling policies evaluate metrics over configured periods and use those measurements to determine whether scaling action is needed.

Reviewing the metric over the relevant period helps us understand:

  • Whether CPU utilization remained high.

  • Whether the configured threshold was reached.

  • Whether the metric returned to normal.

  • Whether a scaling action was triggered.

This gives a more accurate picture of application behavior than relying on one screenshot or one CPU reading.

Terraform and Security

12. Why is Terraform state important, and why was it stored in S3?

Terraform state records the resources managed by Terraform and maps them to the configuration.

Terraform uses this information to understand the existing infrastructure and determine what changes are needed during future operations.

In this project, the state file was stored in an Amazon S3 bucket instead of being maintained only on the local machine.

This provides centralized remote storage and makes state management easier across different working environments.

For additional protection, S3 bucket versioning is recommended. It maintains previous versions of the state file, which can help recover from accidental changes or overwrites.

13. What does use_lockfile = true provide in the S3 backend?

The setting enables native S3 state locking.

When a Terraform operation needs to modify the state, the lock helps prevent conflicting operations from modifying the same state simultaneously.

This reduces the risk of concurrent state updates.

For this project, native S3 locking was used instead of DynamoDB-based locking.

14. Why should state files, local variable files containing sensitive values, AWS credentials and private SSH keys stay out of Git?

These files may contain sensitive information that could expose cloud infrastructure or provide unauthorized access.

For example:

  • Terraform state may contain sensitive resource attributes.

  • terraform.tfvars may contain environment-specific or confidential values.

  • AWS credentials can provide access to an AWS account.

  • Private SSH keys can allow unauthorized access to EC2 instances.

The .gitignore file helps prevent these files from being accidentally committed.

However, .gitignore alone is not a security boundary. Always review staged files before committing:

git status

If sensitive credentials are accidentally published, removing the file from Git is not enough. Revoke or rotate the exposed credentials immediately.

Final Learning Outcome

By completing this project, I gained practical experience with:

  • Designing AWS networking using VPCs, public and private subnets, route tables and NAT.

  • Deploying an internet-facing Application Load Balancer with private EC2 targets.

  • Understanding target group health checks and instance replacement.

  • Configuring Auto Scaling Groups and CPU target tracking policies.

  • Reviewing CloudWatch metrics and Auto Scaling activity history.

  • Managing AWS infrastructure using Terraform and an S3 remote backend.

  • Applying basic security practices for IAM permissions, SSH access and sensitive files.

These questions can also be used for AWS, Terraform and DevOps technical revision and interview preparation.



15. Project Repository and Video Walkthrough

The complete Terraform configuration and supporting project files are available on GitHub.

GitHub Repository:
https://github.com/withmalathi/aws-vpc-alb-asg-terraform

You can explore the Terraform files, architecture diagrams, screenshots and README to understand how the infrastructure is provisioned.

Video Demonstration:
https://www.youtube.com/watch?v=QBvtP7k77KQ&t=7s

The video complements this article with a visual walkthrough of the implementation.

The project is shared for learning and practice. Review the AWS configuration and estimated costs before deploying it in your own account.


16. Technologies Used

TechnologyUsage
AWS VPCNetwork isolation
AWS EC2Compute instances
AWS IAMIdentity and permissions
AWS Internet GatewayPublic internet connectivity
AWS NAT GatewayPrivate subnet outbound connectivity
AWS Application Load BalancerApplication traffic distribution
AWS Target GroupsTarget registration and health checks
AWS Auto ScalingInstance capacity management
AWS CloudWatchMonitoring and alarms
Amazon S3Terraform remote state
TerraformInfrastructure as Code
AWS CLIAWS command-line operations
Linux UbuntuDevelopment and application environment
NGINXWeb server
stress-ngControlled CPU load generation
Git and GitHubVersion control and source repository
WSL UbuntuLocal development environment

17. Disclaimer

This project is intended for educational and demonstration purposes.

The infrastructure was deployed in AWS, tested and subsequently destroyed. The screenshots are historical evidence from the original deployment.

The project uses a simplified learning architecture. Before using a similar design in production, review:

  • IAM least-privilege permissions.

  • HTTPS and certificate management.

  • NAT Gateway availability and cost.

  • Application health checks.

  • Monitoring and alerting.

  • Secrets management.

  • Network security.

  • Terraform state security.

  • Backup and disaster recovery requirements.

Always review Terraform plans and potential AWS costs before applying infrastructure changes.


Learn by Building. Understand by Doing.

✅ Quick check

3 questions to see what stuck.

1. Why are application EC2 instances placed in private subnets?
2. Which AWS service distributes incoming HTTP requests across registered targets?
3. What does Terraform use its state file for?
📚 Sources
  1. docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html
  2. docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html
  3. docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html
  4. docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html
  5. developer.hashicorp.com/terraform/language/backend/s3
  6. registry.terraform.io/providers/hashicorp/aws/latest/docs

❓ Questions readers ask

What is a Multi-AZ architecture in AWS?

A Multi-AZ architecture distributes resources across multiple Availability Zones to improve availability and reduce dependence on a single location.

Why are EC2 instances deployed in private subnets?

Private subnets prevent direct internet access to application instances. Incoming application traffic can reach them through the Application Load Balancer.

What is the role of an Application Load Balancer?

An Application Load Balancer receives incoming HTTP or HTTPS requests and routes them to registered targets based on its listener and routing rules.

What is the difference between an ALB health check and an Auto Scaling policy?

An ALB health check determines whether a target is healthy enough to receive traffic. An Auto Scaling policy changes the number of instances based on configured scaling conditions.

Why is Terraform state stored in Amazon S3?

An S3 backend stores Terraform state remotely, making it easier to maintain and share infrastructure state instead of relying only on a local state file.

Did CPU-based scaling happen during this project?

No CPU-triggered scale-out was confirmed during the recorded test. The project did demonstrate replacement of an unhealthy instance after an ELB health check failure.

Read next →Multi-Cloud Linux Deployment on AWS and Azure⏱ 11 min

🛍️ Malathi Shetty's shelf

Courses, cohorts and more from the author
Malathi Shetty
Written by Malathi Shetty
Senior QA Engineer | Cloud & DevOps Learner | AWS | Azure | Kubernetes | Hands-on Projects
🏅 Contributor writer

I am a technology professional with 13+ years of experience in Software Quality Engineering, currently expanding my expertise in Cloud and DevOps. I enjoy learning by building hands-on projects, exploring cloud technologies and sharing practical knowledge through blogs and labs.

Visit my ByteStoreLearning, building and sharing practical Cloud & DevOps experiences.

🌟 See Malathi Shetty's full profile: blogs, work and verified certificates

Get Malathi Shetty's next blog by email

One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.

We email you once to confirm. By subscribing you agree to the privacy policy.

💬 Comments (0)

Top · Newest

Sign in to comment

Related blogs

🛍️✨ From the author · ByteStore1:1 DevOps Project & Learning Discussionโ‚น500View offer →