#!/bin/bash # AWS Amazon Linux 2 yum install -y nginx systemctl start nginx systemctl enable nginx TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` PH=`curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/public-hostname` echo "This is my instance ${PH}" > /usr/share/nginx/html/index.html