File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,18 @@ is_running_on_gcp() {
4747# Function to detect if running on AWS using IMDSv2 only
4848is_running_on_aws () {
4949 local timeout=5
50- local response=$( curl -s -w " \n%{http_code}" -m " ${timeout} " -X PUT \
50+ local response
51+ local http_code
52+ local token
53+
54+ response=$( curl -s -w " \n%{http_code}" -m " ${timeout} " -X PUT \
5155 " http://169.254.169.254/latest/api/token" \
5256 -H " X-aws-ec2-metadata-token-ttl-seconds: 21600" 2> /dev/null)
5357
54- local http_code=$( echo " $response " | tail -n1)
58+ http_code=$( echo " $response " | tail -n1)
5559 [ " $http_code " != " 200" ] && return 1
56- local token=$( echo " $response " | head -n-1)
60+
61+ token=$( echo " $response " | head -n-1)
5762 curl -s -m " ${timeout} " -H " X-aws-ec2-metadata-token: ${token} " \
5863 " http://169.254.169.254/latest/meta-data/" > /dev/null 2>&1
5964}
You can’t perform that action at this time.
0 commit comments