Skip to content

Commit

Permalink
Enable AWS check with IMDSv2 (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
itcarroll authored Dec 4, 2023
1 parent 1d6b496 commit bd6dce8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

* Bug fixes:
* Follow Amazon EC2 IMDSv2 requirements to set `running-in-aws`

## [v0.8.1] 2023-12-01
* New Features:
* Add `kerchunk` metadata consolidation utility.
Expand Down
6 changes: 4 additions & 2 deletions earthaccess/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ def _am_i_in_aws(self) -> bool:
session = self.auth.get_session()
try:
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
resp = session.get(
"http://169.254.169.254/latest/meta-data/public-ipv4", timeout=1
resp = session.put(
"http://169.254.169.254/latest/api/token",
headers={"X-aws-ec2-metadata-token-ttl-seconds": "21600"},
timeout=1,
)
except Exception:
return False
Expand Down

0 comments on commit bd6dce8

Please sign in to comment.