[cloud] Add support for AWS IMDSv2

Use an HTTP PUT request to fetch a session token, and pass this token
value as a header when fetching the user-data script.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-07-14 13:10:19 +01:00
parent 9e2bf0e940
commit 345abfba19
+17 -1
View File
@@ -19,6 +19,22 @@ exit
:dhcp_ok
route ||
chain -ar http://169.254.169.254/latest/user-data ||
# Fetch session token
params --method PUT
param --header X-Aws-Ec2-Metadata-Token-Ttl-Seconds 600
imgset authtoken http://169.254.169.254/latest/api/token##params ||
# Fetch user-data
params
isset ${authtoken} && param --header X-Aws-Ec2-Metadata-Token ${authtoken} ||
kernel http://169.254.169.254/latest/user-data##params ||
imgstat ||
# Boot from user-data
boot -ar ||
# Show diagnostic information on failure
imgstat ||
ifstat ||
exit