npezzotti / terraform-alb-asg-nginx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

terraform-alb-asg-nginx

This project deploys Nginx on Amazon Linux 2022 instances within a load-balanced autoscaling group, similar to the architecture shown in this AWS tutorial using Terraform.

Prerequisites

  1. Terraform installed
  2. AWS credentials configured

Directions

Create SSH key:

mkdir .ssh
ssh-keygen -t rsa -b 4096 -m pem -f .ssh/tf-alb-asg-ec2-dev-key

Create a terraform.tfvars file with the following content:

environment   = "dev"
instance_type = "t2.micro"
project_name  = "tf-alb-asg-ec2"
ssh_key_path  = ".ssh"
region        = "us-east-1"

Deploy infrastructure:

terraform init
terraform apply

Access website

Open the application url in browser:

open $(terraform output -raw application_url)

Access instances

Choose one of the public DNS names printed by the local-exec provisioner and ssh as ec2-user using created private key`:

ssh -i .ssh/tf-alb-asg-ec2-dev-key ec2-user@<PUBLIC_DNS_OR_IP>

About


Languages

Language:HCL 81.9%Language:Shell 18.1%