From 52dd48e7f7390a76038ac86809a5260ea3840eb8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:14:30 +0000 Subject: [PATCH 1/2] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v2.3.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v2.3.0...v4.5.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 915a8913..600c8027 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 From bd6dce835104962ab775bf33043e980f7116d629 Mon Sep 17 00:00:00 2001 From: Ian Carroll Date: Mon, 4 Dec 2023 17:58:41 -0500 Subject: [PATCH 2/2] Enable AWS check with IMDSv2 (#391) --- CHANGELOG.md | 5 +++++ earthaccess/store.py | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 223482d4..5c07deaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/earthaccess/store.py b/earthaccess/store.py index 940b8aec..8569be26 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -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