Created
October 26, 2014 21:47
-
-
Save nl5887/0f74155e2ea36b0fb3bb to your computer and use it in GitHub Desktop.
Shows metadata about the current cloud instance. For use in logon scripts or prompts.
This file contains 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/sh | |
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html | |
instanceid=`curl http://169.254.169.254/latest/meta-data/instance-id -s` | |
amiid=`curl http://169.254.169.254/latest/meta-data/ami-id -s` | |
hostname=`curl http://169.254.169.254/latest/meta-data/hostname -s` | |
instancetype=`curl http://169.254.169.254/latest/meta-data/instance-type -s` | |
kernelid=`curl http://169.254.169.254/latest/meta-data/kernel-id -s` | |
securitygroups=`curl http://169.254.169.254/latest/meta-data/security-groups -s` | |
publichostname=`curl http://169.254.169.254/latest/meta-data/public-hostname -s` | |
availabilityzone=`curl http://169.254.169.254/latest/meta-data/placement/availability-zone -s` | |
userdata=`curl http://169.254.169.254/latest/user-data -s -f` | |
echo " | |
=============================================================================================== | |
# Instance-id: $instanceid | |
# AMI-id: $amiid | |
# | |
# Public: $publichostname | |
# Private: $hostname | |
# | |
# Availability zone: $availabilityzone | |
# Instance type: $instancetype | |
# | |
# Security groups: | |
# $securitygroups | |
================================================================================================ | |
$userdata | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment