user-data-basic
#!/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 "<body style='background-color:rgb($((RANDOM%256)),$((RANDOM%256)),$((RANDOM%256)))'>This is my instance ${PH}</body>" > /usr/share/nginx/html/index.html
Comments
0 B
|π
/π
0 B
|π
/π