]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cloud] Add support for AWS IMDSv2
authorMichael Brown <mcb30@ipxe.org>
Tue, 14 Jul 2026 12:10:19 +0000 (13:10 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 14 Jul 2026 12:10:19 +0000 (13:10 +0100)
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>
src/config/cloud/aws.ipxe

index c1f40f3402b1d3976a552ad1dd5485856dc06bbe..11891f1a09c004a9c5a8030b7dd935ecb3055606 100644 (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