Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/nsidc/earthaccess into chec…
Browse files Browse the repository at this point in the history
…k-region
  • Loading branch information
jrbourbeau committed Dec 4, 2023
2 parents 8ceb383 + bd6dce8 commit 86f98d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: trailing-whitespace
Expand Down
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
9 changes: 8 additions & 1 deletion earthaccess/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,15 @@ def _running_in_us_west_2(self) -> bool:
session = self.auth.get_session()
try:
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
token_ = session.put(
"http://169.254.169.254/latest/api/token",
headers={"X-aws-ec2-metadata-token-ttl-seconds": "21600"},
timeout=1,
)
resp = session.get(
"http://169.254.169.254/latest/meta-data/placement/region", timeout=1
"http://169.254.169.254/latest/meta-data/placement/region",
timeout=1,
headers={"X-aws-ec2-metadata-token": token_.text},
)
except Exception:
return False
Expand Down

0 comments on commit 86f98d4

Please sign in to comment.