User Data = Bash script that runs automatically when EC2 first launches


Purpose:

Automate initial setup:

Key Points:

Runs only once at first boot

Runs as root (no need for sudo)

Must start with: #!/bin/bash

Perfect for automation at launch


Example User Data:

#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Auto-deployed!</h1>" > /var/www/html/index.html

Why it's the answer:

SSH manually = slow, not scalable

Contact AWS Support = unnecessary