The CloudFormation stack successfully deploys an EC2 instance running Apache. The web server is accessible via the stack output URL.
Deploys a simple EC2 web server using AWS CloudFormation. This project demonstrates Infrastructure as Code (IaC), security best practices, and automated software installation.
- EC2 Instance: Amazon Linux 2 (t2.micro)
- Security Group:
- HTTP (80) open to the world
- SSH (22) configurable via parameter (can be locked to a single IP)
- User Data: Installs and starts Apache, serves a basic web page
- AWS Account
- AWS CLI installed (optional for CLI deployment)
- EC2 Key Pair for SSH access
- Go to CloudFormation → Create stack → With new resources (standard)
- Upload
template.yaml - Enter parameters:
KeyName: your EC2 key pairSSHLocation: your IP in CIDR format (e.g.,203.0.113.45/32)
- Click Create stack
- Wait for
CREATE_COMPLETE
aws cloudformation create-stack \
--stack-name ec2-webserver-stack \
--template-body file://template.yaml \
--parameters ParameterKey=KeyName,ParameterValue=YOUR_KEY_NAME ParameterKey=SSHLocation,ParameterValue=YOUR_IP/32 \
--region us-east-1