File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,20 @@ else
130130fi
131131echo
132132
133- echo " Instance type from IMDS (if available):"
134- curl -s --connect-timeout 1 ' http://169.254.169.254/latest/meta-data/instance-type' | tee instance.txt
133+ echo " Instance type from Metadata service (if available):"
134+ AWS_HTTP_CODE=$( curl -s -o /dev/null -w " %{http_code}" --connect-timeout 1 ' http://169.254.169.254/latest/meta-data/' )
135+ if [[ " $AWS_HTTP_CODE " == " 200" ]]; then
136+ AWS_INSTANCE_TYPE=$( curl -s --connect-timeout 1 ' http://169.254.169.254/latest/meta-data/instance-type' )
137+ echo " $AWS_INSTANCE_TYPE " > instance.txt
138+ exit 0
139+ fi
140+
141+ GCP_HTTP_CODE=$( curl -s -o /dev/null -w " %{http_code}" --connect-timeout 1 -H " Metadata-Flavor: Google" ' http://metadata.google.internal/computeMetadata/v1/instance/' )
142+ if [[ " $GCP_HTTP_CODE " == " 200" ]]; then
143+ GCP_INSTANCE_TYPE=$( curl -s --connect-timeout 1 -H " Metadata-Flavor: Google" ' http://metadata.google.internal/computeMetadata/v1/instance/machine-type' | awk -F/ ' {print $NF}' )
144+ echo " $GCP_INSTANCE_TYPE " > instance.txt
145+ exit 0
146+ fi
135147echo
136148
137149echo " Uploading the results (if possible)"
You can’t perform that action at this time.
0 commit comments