The market network is built: four subnets, the public and private route tables, and the internet gateway on public. The web server's script is in ~/web.sh.
-
Keep the VPC's id in
VPCandpublic-a's id inSUBNET:shSUBNET=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=public-a --query "Subnets[0].SubnetId" --output text) -
Make
public-ahand out public IPs. -
Create a security group
webin the VPC that lets in TCP 80 from anywhere, keeping its id inSG. -
Put today's Amazon Linux 2023 image id in
AMI, as in Chapter 3. -
Launch a
t3.micronamedwebinpublic-awith that group and~/web.shas user data. -
Point
SUBNETatprivate-ainstead:shSUBNET=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=private-a --query "Subnets[0].SubnetId" --output text) -
Launch a
t3.micronamedappthere, with the same group and no user data. -
Wait a minute, then curl
webon its public IP.