Skip to content

Using Terraform to automate creation of VPC, Auto Scaling Group and Application Load Balancer with ACM SSL certificate for a high available website

Notifications You must be signed in to change notification settings

MarkAntonyGit/Terraform_ASG-ALB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform_ASG-ALB

Using Terraform to automate creation of VPC, Auto Scaling Group and Application Load Balancer with ACM SSL certificate for a high available website

Description

Terraform is an infrastructure as a code (IAAC) tool created by HashiCorp which can be used for managing infrastructure with various technologies like Amazon AWS, Microsoft Azure, Google Cloud, and vSphere etc.

In this project I have used Terraform for creating a VPC with private and public Subnets and Network Gateway's for the VPC. We will be making 1 VPC with 6 Subnets: 3 Private and 3 Public, 1 NAT Gateways, 1 Internet Gateway, and 2 Route Tables. I have also created a Application Load Balancer with SSL certificate from Amazon Certificate Manager and an Auto Scaling Group using a sample Launch Configuration to host a highly available sample website on AWS infrastructure. All of the resources will be inside the custom VPC we have created. All these resource creation can be automated with desired values and you can use this whenever you need to create a similar setup.

Architecture Image

Features

  • Easy to customise with terraform.tfvars file. All variables can be modified quickly.
  • VPC is added with 3 public subnets and 3 private subnets in different availability zones and can use to expand the infrastructure easily.
  • Project name is appended to the resources that are creating which will make easier to identify the resources.

Prerequisites

  • Create an IAM user on your AWS console that have access to create the required resources.
  • Import/Add SSL certificate on Amazon Certificate Manager to use for ALB.

How to use?

To install Terraform
wget https://releases.hashicorp.com/terraform/0.15.3/terraform_0.15.3_linux_amd64.zip
unzip terraform*.zip
mv -f terraform /usr/bin/
To execute this terraform code
yum install git unzip -y
git clone https://github.com/MarkAntonyGit/Terraform_ASG-ALB.git
cd Terraform_ASG-ALB
vim terraform.tfvars - Make Necessary Changes.
terraform init
terraform validate
terraform plan
terraform apply
Update Website DNS Records

-Once the terraform apply is completed you will get the load balancer public DNS from the outputs. Do update the same as a CNAME record for your desired domain or if you are using AWS Route 53, you can point the domain to ALB with an A record alias.

sample screenshots

-tfvars file

-Resources Created

-Sample Website Screenshots

Connect with me

-------- ----------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------------

About

Using Terraform to automate creation of VPC, Auto Scaling Group and Application Load Balancer with ACM SSL certificate for a high available website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published