brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

Use two-step token request for Instance MetaData #831

Closed pbrisbin closed 1 year ago

pbrisbin commented 1 year ago

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html

A few caveats:

Closes #745.

pbrisbin commented 1 year ago

Thanks for the review, addressing these things now. Is there a reason isEC2 uses "http://instance-data/latest", while the rest of the calls use "http://169.254.169.254/latest/"? Does that need to be preserved? It makes it annoying to DRY the token-handling and is the reason I missed it on first coding.

EDIT: it was trivial to preserve, as far as I can tell, so I did.

endgame commented 1 year ago

Is there a reason isEC2 uses "http://instance-data/latest", while the rest of the calls use "http://169.254.169.254/latest/"?

I believe that in most cases, it's faster to attempt name resolution and have a local nameserver reply "nope", than it is to wait for an addressed TCP connection to the IMDS address to fail to open. Otherwise, you get a stall in any amazonka program not running on EC2 if the earlier auth methods fail to find keys.

pbrisbin commented 1 year ago

Thanks for the quick merge!