diff --git a/ec2-metadata b/ec2-metadata index 8405682..ca84f96 100755 --- a/ec2-metadata +++ b/ec2-metadata @@ -41,7 +41,8 @@ Options: -s/--security-groups Names of the security groups the instance is launched in. Only available if supplied at instance launch time -d/--user-data User-supplied data.Only available if supplied at instance launch time. -g/--tags Tags assigned to this instance. ---quiet Suppress tag keys from the output." +--quiet Suppress tag keys from the output. +--url Override base URL for metadata server (default http://169.254.169.254)" } METADATA_BASEURL="http://169.254.169.254" @@ -156,9 +157,6 @@ function print_all() print_tags } -#check if run inside an EC2 instance -set_imds_token - #command called in default mode if [ "$#" -eq 0 ]; then print_all @@ -169,7 +167,7 @@ shortopts=almnbithokzPcpvuresdgR longopts=(ami-id ami-launch-index ami-manifest-path ancestor-ami-ids block-device-mapping instance-id instance-type local-hostname local-ipv4 kernel-id availability-zone partition product-codes public-hostname public-ipv4 public-keys ramdisk-id - reservation-id security-groups user-data tags region help all quiet) + reservation-id security-groups user-data tags region help all quiet url:) oldIFS="$IFS" IFS=, @@ -192,6 +190,10 @@ while true; do --quiet) QUIET=1 ; shift ;; + --url) + shift + METADATA_BASEURL=$1; shift + ;; --) shift ; break ;; @@ -207,6 +209,9 @@ while true; do esac done +#check if run inside an EC2 instance +set_imds_token + #start processing command line arguments for action in "${actions[@]}"; do case "$action" in