Last active
January 7, 2019 09:35
-
-
Save samof76/7415f0874a552316c58d57b033a65d62 to your computer and use it in GitHub Desktop.
confd.sh
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 | |
# Get the instance id | |
instance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id 2> /dev/null) | |
# Get the instance name | |
instance_hostname=$(aws ec2 describe-instances --instance-ids $instance_id | jq -r '.Reservations[0].Instances[0].Tags[] | select(.Key == "opsworks:instance") | .Value') | |
# Get the instance ip | |
instance_ipaddress=$(aws ec2 describe-instances --instance-ids $instance_id | jq -r '.Reservations[0].Instances[0].PrivateIpAddress') | |
uptime > /root/confd.txt | |
echo $instance_id >> /root/confd.txt | |
echo $instance_hostname >> /root/confd.txt | |
echo $instance_ipaddress >> /root/confd.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment