Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposed enhancement] AWS us-west-2 checking method #231

Open
battistowx opened this issue Apr 13, 2023 · 5 comments · May be fixed by #424
Open

[proposed enhancement] AWS us-west-2 checking method #231

battistowx opened this issue Apr 13, 2023 · 5 comments · May be fixed by #424

Comments

@battistowx
Copy link
Collaborator

In some of our DAAC notebooks, we include the following Boto3 snippet to check if the notebook is being executed inside us-west-2, and throws a ValueError (with emojis) if you are not, preventing the notebook from being fully executed:

if (boto3.client('s3').meta.region_name == 'us-west-2'):
    display(Markdown('### us-west-2 Region Check: ✅'))
else:
    display(Markdown('### us-west-2 Region Check: ❌'))
    raise ValueError('Your notebook is not running inside the AWS us-west-2 region, and will not be able to directly access NASA Earthdata S3 buckets')

It may be useful to include a method that the user can call to check if they are in us-west-2 for direct S3 access and will throw an error like this, possibly using an fsspec transitive dependency, or the existing authorization checks.

@battistowx battistowx changed the title AWS us-west-2 checking method [enhancement] AWS us-west-2 checking method Apr 13, 2023
@battistowx battistowx changed the title [enhancement] AWS us-west-2 checking method [proposed enhancement] AWS us-west-2 checking method Apr 13, 2023
@betolink
Copy link
Member

This sounds great @battistowx we should pair this week or the next one if you have time, it should be a simple thing to implement with your code!

@battistowx
Copy link
Collaborator Author

Found methods to use requests to grab the current instance's region from the locally-linked Instance Identity Document, and it works great! https://gist.github.com/doublenns/7e3e4b72df4aaeccbeabf87ba767f44e

Wondering if this should be its own function that a user could call anywhere, or if it should be called only when an S3 granule is opened, which would print a detailed exception statement.

@JessicaS11
Copy link
Collaborator

I'd be interested in helping implement this in some fashion - we're updating related functionality in icepyx and I'd love to just put it upstream and then use it.

@betolink
Copy link
Member

I think it would be great if we can expose earthaccess.__store__.in_region to earthaccess.in_region(default="us-west-2") and perhaps using an nicely formatted repr output besides the boolean value?

@JessicaS11 JessicaS11 linked a pull request Jan 8, 2024 that will close this issue
@JessicaS11
Copy link
Collaborator

Could someone clarify for #424:

was the spirit to check specifically for us-west-2, or to enable the user to see what region they are running in?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

3 participants