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.
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
Open the application url in browser:
open $(terraform output -raw application_url)
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>