Skip to content

Instantly share code, notes, and snippets.

@joshkitt
Last active July 30, 2020 15:19
Show Gist options
  • Save joshkitt/297da727d6e3f7c822bf67462f1ab46f to your computer and use it in GitHub Desktop.
Save joshkitt/297da727d6e3f7c822bf67462f1ab46f to your computer and use it in GitHub Desktop.
AWS EC2 User Data with Java
#!/bin/bash
sudo su
yum update -y
yum install -y httpd
amazon-linux-extras install java-openjdk11
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