echo "---> capture-instance-metadata.sh"
+# shellcheck disable=SC1090
+source ~/lf-env.sh
+
+lf-activate-venv --python python3.8 lftools
+
# detect if we're in EC2
if [ -n "${NOMAD_DC}" ]; then
echo "INFO: Running in Nomad, no metadata"
exit 0
fi
-# detect if we're in AWS
-if grep -qi amazon /sys/devices/virtual/dmi/id/bios_vendor ; then
+if [[ ! -f /run/cloud-init/result.json ]]; then
+ echo "INFO: Running in unsupported cloud, no metadata"
+ exit 0
+fi
+
+# AWS not supported, exit
+cloudtype="$(jq -r .v1.datasource /run/cloud-init/result.json)"
+if [[ $cloudtype == "DataSourceEc2Local" ]]; then
echo "INFO: Running in AWS, not capturing instance metadata"
exit 0
fi