Just the basics/defaults in setting up an EC2 instance with an Application Load Balancer (ALB) in front of it.
Goto EC2 -> Instances -> Launch Instance
Leave the defaults. Select an ssh key or click on Create new key pair.
Expand Advanced details and leave everything as is, but paste into the User data field:
#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html
Click on Launch instance.
Create the ALB. Goto EC2 -> Load Balancers and click on Create Load Balancer
Under Load Balancer Types -> Application Load Balancer -> Click Create.
Leave the Basic Configuration presets as they are.
Under Network mapping, select the default VPC and all the subnets offered.
Under Security Groups, select load-balancer-wizard-1 or create it with the following rules:


If you created the security group, back at the Create Applicaion Load Balancer page, under Security Groups, refresh the drop down menu and select it.
Under Listeners and routing, click on Create Target Group. Under Specify Group Details, leave all defaults as is, enter a Target Group Name and click on Next.
Select the instance created above to register it with the target group. Click on Include as pending below and click on Register pending targets.
Go back to the Create Application Load Balancer form, under Listeners and routing, refresh the target group drop down menu and select the target group created above.
Click on Create load balancer. The details of the created load balancer should display. (If not, go to the Load Balancer list and select the load balancer you created.) Under Description, copy the DNS name and paste it into your browser. Be sure to use http if that's what you used only.
The Hello World message should load.
Remember: ALB -> Listeners -> Target Group -> Instance
Good notes here.
Troubleshooting:
Load the instance directly. If it doesn't load, solve that first.
If the instance is not loading directly, check the Inbound Rules of the instance's security group.
Be sure correct protocol is used when calling the instance in your browser; http vs https.
TODO: Only allow access to instance through the ALB:
