Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Terraform AWS HTTPS Application Load Balancer

Overview

This project provisions a secure HTTPS web application on AWS using Terraform. It deploys an Application Load Balancer (ALB) that distributes traffic to an Amazon EC2 instance running Nginx, secures the application with an existing AWS Certificate Manager (ACM) certificate, and exposes the application through a custom domain managed by Amazon Route 53.

The project demonstrates how to build a production-style HTTPS architecture while separating shared infrastructure resources, such as Route 53 and ACM, from application-specific infrastructure.


Architecture

                Internet
                    │
                    ▼
             Amazon Route 53
                    │
                    ▼
          AWS Certificate Manager
                    │
                    ▼
      Application Load Balancer (HTTPS)
                    │
                    ▼
             Target Group
                    │
                    ▼
           Amazon EC2 (Nginx)

AWS Services Used

  • Amazon VPC
  • Public Subnets
  • Internet Gateway
  • Route Tables
  • Security Groups
  • Amazon EC2
  • Application Load Balancer (ALB)
  • Target Group
  • AWS Certificate Manager (ACM)
  • Amazon Route 53
  • Amazon S3 (Terraform Remote Backend)
  • GitHub Actions (CI/CD)

Project Objectives

  • Provision infrastructure using Terraform.
  • Deploy an internet-facing Application Load Balancer.
  • Configure HTTPS using an existing ACM certificate.
  • Route traffic through a custom Route 53 domain.
  • Deploy an EC2 instance with Nginx using user data.
  • Store Terraform state remotely in Amazon S3.
  • Deploy infrastructure through GitHub Actions.

Repository Structure

.
├── .github/
│   └── workflows/
├── backend.tf
├── provider.tf
├── variables.tf
├── outputs.tf
├── networking.tf
├── security.tf
├── compute.tf
├── loadbalancer.tf
├── route53.tf
├── userdata.sh
├── README.md
└── .gitignore

Infrastructure Components

Networking

  • Custom VPC
  • Two public subnets
  • Internet Gateway
  • Public route table
  • Route table associations

Security

Two security groups are used:

Application Load Balancer Security Group

Allows:

  • HTTP (80)
  • HTTPS (443)

from the Internet.

EC2 Security Group

Allows:

  • HTTP (80)

only from the ALB Security Group.


HTTPS Configuration

This project reuses an existing ACM certificate that was created and validated in a separate Terraform project.

The certificate is referenced using Terraform data sources instead of being recreated.

data "aws_acm_certificate" "main" {
  domain      = var.domain_name
  statuses    = ["ISSUED"]
  most_recent = true
}

Route 53

The hosted zone is referenced as an existing resource.

Terraform creates only the DNS Alias record pointing the domain to the Application Load Balancer.


Deployment Workflow

  1. Clone the repository.
  2. Configure AWS credentials.
  3. Initialize Terraform.
terraform init
  1. Validate the configuration.
terraform validate
  1. Review the execution plan.
terraform plan
  1. Deploy the infrastructure.
terraform apply

Verification

After deployment verify the following:

  • HTTPS is accessible.
  • SSL certificate is valid.
  • Route 53 Alias record resolves correctly.
  • ALB Target Group is healthy.
  • EC2 instance is running.
  • Nginx returns the application page.

Terraform Outputs

The project provides:

  • Website URL
  • Application Load Balancer DNS Name

CI/CD

Infrastructure deployment is automated using GitHub Actions.

The workflow performs:

  • Terraform Init
  • Terraform Validate
  • Terraform Plan
  • Terraform Apply

AWS credentials are securely stored as GitHub Secrets.


Lessons Learned

This project reinforced several important Terraform and AWS concepts:

  • Designing HTTPS architectures using ALB and ACM.
  • Reusing shared infrastructure with Terraform data sources.
  • Separating infrastructure ownership across projects.
  • Using remote Terraform state in Amazon S3.
  • Refactoring large Terraform configurations into modular files.
  • Debugging Application Load Balancer target health.
  • Understanding the difference between Terraform resources and data sources.
  • Safely migrating Terraform state without destroying shared resources.

Challenges Solved

During development the following issues were identified and resolved:

  • Terraform state migration between projects.
  • Shared ACM certificate ownership.
  • Route 53 resource ownership.
  • ALB returning HTTP 503 due to missing target registration.
  • Target Group attachment configuration.
  • Security Group communication between ALB and EC2.
  • HTTPS validation and DNS propagation.

Future Improvements

Possible enhancements include:

  • Auto Scaling Group
  • Launch Template
  • Multiple Availability Zones
  • AWS WAF
  • CloudFront
  • AWS Systems Manager Session Manager
  • CloudWatch monitoring and alarms
  • AWS Backup
  • Private subnets
  • NAT Gateway

Screenshots

Recommended screenshots to include:

  • Terraform Apply
  • Route 53 Hosted Zone
  • ACM Certificate (Issued)
  • Application Load Balancer
  • Target Group (Healthy)
  • EC2 Instance
  • HTTPS website
  • GitHub Actions successful deployment

Author

Terraform AWS Infrastructure Portfolio Project

Focus Areas:

  • Infrastructure as Code
  • Terraform
  • Amazon Web Services
  • Networking
  • HTTPS
  • Application Load Balancer
  • Route 53
  • GitHub Actions

Amazon Route 53 Hosted Zone

Amazon Route 53 manages the DNS records for the custom domain and routes traffic to the Application Load Balancer.

Amazon Route 53 Hosted Zone

Application Load Balancer

The Application Load Balancer distributes incoming traffic across EC2 instances and terminates HTTPS connections using an ACM-issued certificate.

Application Load Balancer Overview

Application Load Balancer Listeners

The load balancer redirects all HTTP traffic (port 80) to HTTPS (port 443). HTTPS requests are terminated using an AWS Certificate Manager (ACM) certificate and forwarded to the target group.

Application Load Balancer Listeners

Amazon EC2 Instance

The application is hosted on an Amazon EC2 instance running Nginx. The instance is registered with the Application Load Balancer target group and successfully passes all health checks.

Amazon EC2 Instance

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages