at 22.05-pre 770 B view raw
1{ targetRoot, wgetExtraOptions }: 2 3# OpenStack's metadata service aims to be EC2-compatible. Where 4# possible, try to keep the set of fetched metadata in sync with 5# ./ec2-metadata-fetcher.nix . 6'' 7 metaDir=${targetRoot}etc/ec2-metadata 8 mkdir -m 0755 -p "$metaDir" 9 rm -f "$metaDir/*" 10 11 echo "getting instance metadata..." 12 13 wget_imds() { 14 wget ${wgetExtraOptions} "$@" 15 } 16 17 wget_imds -O "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path 18 (umask 077 && wget_imds -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data) 19 wget_imds -O "$metaDir/hostname" http://169.254.169.254/1.0/meta-data/hostname 20 wget_imds -O "$metaDir/public-keys-0-openssh-key" http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key 21''