2020-11-18 17:42:32 +01:00
|
|
|
{ targetRoot, wgetExtraOptions }:
|
2020-11-21 02:44:25 +01:00
|
|
|
|
|
|
|
# OpenStack's metadata service aims to be EC2-compatible. Where
|
|
|
|
# possible, try to keep the set of fetched metadata in sync with
|
|
|
|
# ./ec2-metadata-fetcher.nix .
|
2020-11-18 17:42:32 +01:00
|
|
|
''
|
|
|
|
metaDir=${targetRoot}etc/ec2-metadata
|
|
|
|
mkdir -m 0755 -p "$metaDir"
|
2020-11-21 02:44:25 +01:00
|
|
|
rm -f "$metaDir/*"
|
2020-11-18 17:42:32 +01:00
|
|
|
|
2020-11-21 01:53:32 +01:00
|
|
|
echo "getting instance metadata..."
|
2020-11-18 17:42:32 +01:00
|
|
|
|
2020-11-21 02:40:38 +01:00
|
|
|
wget_imds() {
|
|
|
|
wget ${wgetExtraOptions} "$@"
|
|
|
|
}
|
|
|
|
|
2020-11-21 02:44:25 +01:00
|
|
|
wget_imds -O "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path
|
2021-05-02 00:28:59 +02:00
|
|
|
(umask 077 && wget_imds -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data)
|
2020-11-21 02:44:25 +01:00
|
|
|
wget_imds -O "$metaDir/hostname" http://169.254.169.254/1.0/meta-data/hostname
|
|
|
|
wget_imds -O "$metaDir/public-keys-0-openssh-key" http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key
|
2020-11-18 17:42:32 +01:00
|
|
|
''
|