Simple Terraform configuration

A Terraform configuration that provisions the following infrastructure:

A VPC with:

  • Public subnets for external resources.
  • Private subnets for internal resources.

EC2 instances:

  • Deployed within the private subnets.
  • Running a web server that displays the hostname of the instance which received the request.
Simple Terraform configuration
Simple Terraform configuration

Requirements:

Autoscaling:

Configure the EC2 instances to scale based on demand using AWS Auto Scaling Groups.

Expose the web application:

Make the web application reachable from the internet while keeping the EC2 instances in the private subnets.

A VPC with:

  • Public subnets for external resources.
  • Private subnets for internal resources.

EC2 instances:

  • Deployed within the private subnets.
  • Running a web server that displays the hostname of the instance which received the request.

Requirements:

Autoscaling:

  • Configure the EC2 instances to scale based on demand using AWS Auto Scaling Groups.

Expose the web application:

  • Make the web application reachable from the internet while keeping the EC2 instances in the private subnets.

Environment

SETUPENV
Provider[AWS]
Region[eu-west-1] [eu-west-1a] [eu-west-1b]
VPC cidr_block[192.168.0.0/16]
Public-Subnet[192.168.0.0/24]
Private-Subnet[192.168.1.0/24]
Route NAT Gateway[cidr_block = “0.0.0.0/0”]
Bastion ec2[t2.micro]
Nginx[t2.micro]
docker image[https://hub.docker.com/r/nginxdemos/hello/]
Security groups[tcp/22 – http/80]
CertManager[NO]
Route53[NO]

References

ResourceURL
Terraform Autoscaling Modulehttps://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/latest
Terraform Autoscaling Policyhttps://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_policy
Terraform Fargatehttps://registry.terraform.io/modules/almirosmanovic/fargate/aws/latest/examples/autoscaling

Explanation from the Readme.md file on the Git Repository