File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed
Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change 44NONOK=1
55UNKNOWN=2
66
7- # Try to get IMDSv2 token (for AL2023)
87TOKEN=$( curl -X PUT " http://169.254.169.254/latest/api/token" \
98 -H " X-aws-ec2-metadata-token-ttl-seconds: 21600" \
109 --max-time 3 --silent --fail 2> /dev/null)
1110
12- # Check spot termination notice
13- if [ -n " $TOKEN " ]; then
14- # Use IMDSv2 if token was obtained (AL2023)
15- status_code=$( curl --max-time 3 --silent --output /dev/stderr --write-out " %{http_code}" \
16- -H " X-aws-ec2-metadata-token: $TOKEN " \
17- " http://169.254.169.254/latest/meta-data/spot/instance-action" )
18- else
19- # Fall back to IMDSv1 (Linux 2)
20- status_code=$( curl --max-time 3 --silent --output /dev/stderr --write-out " %{http_code}" \
21- " http://169.254.169.254/latest/meta-data/spot/instance-action" )
22- fi
11+ status_code=$( curl --max-time 3 --silent --output /dev/stderr --write-out " %{http_code}" \
12+ -H " X-aws-ec2-metadata-token: $TOKEN " \
13+ " http://169.254.169.254/latest/meta-data/spot/instance-action" )
2314
2415if [ " ${status_code} " -eq " 404" ]; then
2516 exit $OK
You can’t perform that action at this time.
0 commit comments