Skip to content

Commit

Permalink
Add region to running in AWS check
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Dec 4, 2023
1 parent 1a45326 commit bed9571
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions earthaccess/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ def _am_i_in_aws(self) -> bool:
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
"http://169.254.169.254/latest/meta-data/placement/region", timeout=1
)
except Exception:
return False
if resp.status_code == 200:

if resp.status_code == 200 and b"us-west-2" == resp.content:
# On AWS in region us-west-2
return True
return False

Expand Down

0 comments on commit bed9571

Please sign in to comment.