Commit 6fb582e0 authored by Linus Heckemann's avatar Linus Heckemann
Browse files

ec2-metadata-fetcher: ignore failure when fetching metadata parts

Instances without SSH keys configured will receive a 404 from the
metadata server when attempting to fetch an SSH key. This is not an
actual problem though, and shouldn't result in the service failing.

If the metadata server cannot be reached, the script will fail at an
earlier stage when attempting to get authentication data.
parent eddfcf86
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -70,8 +70,8 @@
    wget ${wgetExtraOptions} --header "X-aws-ec2-metadata-token: $IMDS_TOKEN" "$@";
  }

  wget_imds -O "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path
  (umask 077 && wget_imds -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data)
  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
  wget_imds -O "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path || true
  (umask 077 && wget_imds -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data || true)
  wget_imds -O "$metaDir/hostname" http://169.254.169.254/1.0/meta-data/hostname || true
  wget_imds -O "$metaDir/public-keys-0-openssh-key" http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key || true
''