Skip to content

Instantly share code, notes, and snippets.

@joshkitt
Last active July 30, 2020 15:21
Show Gist options
  • Save joshkitt/f8788d57b7b8ae6bfb8240ef575dde15 to your computer and use it in GitHub Desktop.
Save joshkitt/f8788d57b7b8ae6bfb8240ef575dde15 to your computer and use it in GitHub Desktop.
AWS EC2 User Data Example
#!/bin/bash
sudo su
yum update -y
yum install -y httpd
systemctl start httpd.service
systemctl enable httpd.service
EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
echo "<h1>Hello World from $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1>" > /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment