From bed9571bc657754db0c25b6e18a9530348d81005 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Mon, 4 Dec 2023 12:16:20 -0600 Subject: [PATCH] Add region to running in AWS check --- earthaccess/store.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/earthaccess/store.py b/earthaccess/store.py index f2f3618e..173e1f47 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -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