Created
February 13, 2024 08:59
-
-
Save hiteshchoudhary/3a542e1f7294c1b7fe919e98892b4a2c to your computer and use it in GitHub Desktop.
Install apache on AWS with metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install -y httpd | |
systemctl start httpd | |
systemctl enable httpd | |
EC2AZ=$(TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") \ | |
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/placement/availability-zone) | |
echo "<body style='background-color:#2c3e50; color:#ffffff'><h1>Deployed via AWS</h1><br><h2>Availability Zone: $EC2AZ</h2> </body>" > /var/www/html/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment