···55echo "getting EC2 instance metadata..."
5657get_imds() {
58- # Intentionally no --fail here, so that we proceed even if e.g. a
59- # 404 was returned (but we still fail if we can't reach the IMDS
60- # server).
61- curl --silent --show-error --header "X-aws-ec2-metadata-token: $IMDS_TOKEN" "$@"
62}
6364get_imds -o "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path
···55echo "getting EC2 instance metadata..."
5657get_imds() {
58+ # --fail to avoid populating missing files with 404 HTML response body
59+ # || true to allow the script to continue even when encountering a 404
60+ curl --silent --show-error --fail --header "X-aws-ec2-metadata-token: $IMDS_TOKEN" "$@" || true
061}
6263get_imds -o "$metaDir/ami-manifest-path" http://169.254.169.254/1.0/meta-data/ami-manifest-path