Here is a basic outline for a Bash script that retrieves EC2 meta-data values and generates an HTML document to showcase the data:
curl
command to retrieve the EC2 instance ID and other meta-data values from the EC2 meta-data endpoint:instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
instance_type=$(curl -s http://169.254.169.254/latest/meta-data/instance-type)
public_ip=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
...
echo
command to generate an HTML document with the retrieved values:echo "<html>"
echo "<body>"
echo "<h1>EC2 meta-data values</h1>"
echo "<ul>"
echo "<li>Instance ID: $instance_id</li>"
echo "<li>Instance Type: $instance_type</li>"
echo "<li>Public IP: $public_ip</li>"
...
echo "</ul>"
echo "</body>"
echo "</html>"
./ec2_metadata.sh > metadata.html
Asked: 2023-07-08 22:27:41 +0000
Seen: 7 times
Last updated: Jul 08 '23