Unable to acces GES DISC DATA ARCHIVE from AWS S#
Posted: Fri Dec 01, 2023 7:31 am America/New_York
Hello everyone,
I'm facing difficulties accessing data from the S3 bucket in the us-west-2 zone. I've diligently followed the steps from the AWS official documentation and double-checked multiple times to ensure I'm in the correct zone. Furthermore, I attempted to access the data through an EC2 instance, but I'm still encountering issues.
Here's a snippet of my code:
from netrc import netrc
import os
import requests
import s3fs
urs = 'urs.earthdata.nasa.gov'
netrc_name = ".netrc"
netrcDir = os.path.expanduser(f"~/{netrc_name}")
netrc(netrcDir).authenticators(urs)[0]
gesdisc_s3 = "https://data.gesdisc.earthdata.nasa.gov/s3credentials"
def begin_s3_direct_access(url: str=gesdisc_s3):
response = requests.get(url).json()
return s3fs.S3FileSystem(key=response['accessKeyId'],
secret=response['secretAccessKey'],
token=response['sessionToken'],
client_kwargs={'region_name':'us-west-2'})
fs = begin_s3_direct_access()
fn = 's3://gesdisc-cumulus-prod-protected/GPM_L3/GPM_3IMERGHHE.06/2023/091/3B-HHR-E.MS.MRG.3IMERG.20230401-S000000-E002959.0000.V06C.HDF5'
fs.ls(fn)
However, upon running this code, I receive the following error message:
---------------------------------------------------------------------------
ClientError Traceback (most recent call last)
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/s3fs/core.py:113, in _error_wrapper(func, args, kwargs, retries)
112 try:
--> 113 return await func(*args, **kwargs)
114 except S3_RETRYABLE_ERRORS as e:
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/aiobotocore/client.py:383, in AioBaseClient._make_api_call(self, operation_name, api_params)
382 error_class = self.exceptions.from_code(error_code)
--> 383 raise error_class(parsed_response, operation_name)
384 else:
ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
The above exception was the direct cause of the following exception:
PermissionError Traceback (most recent call last)
/home/gabriel/notebooks/dsfc_nasa/open.py in line 38
35 # Files are organized by s3://gesdisc-cumulus-prod-protected/MERRA2/M2T1NXSLV.5.12.4/year/mo/*.nc4
37 fn = 's3://gesdisc-cumulus-prod-protected/GPM_L3/GPM_3IMERGHHE.06/2023/091/3B-HHR-E.MS.MRG.3IMERG.20230401-S000000-E002959.0000.V06C.HDF5'
---> 38 fs.info(fn)
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/fsspec/asyn.py:118, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
115 @functools.wraps(func)
116 def wrapper(*args, **kwargs):
...
138 err = e
139 err = translate_boto_error(err)
--> 140 raise err
PermissionError: Forbidden
I'd greatly appreciate any guidance or suggestions to resolve this issue. I've reviewed my permissions in the site, followed the steps outlined in the documentation, and am confident I'm in the correct zone.
Thank you.
I'm facing difficulties accessing data from the S3 bucket in the us-west-2 zone. I've diligently followed the steps from the AWS official documentation and double-checked multiple times to ensure I'm in the correct zone. Furthermore, I attempted to access the data through an EC2 instance, but I'm still encountering issues.
Here's a snippet of my code:
from netrc import netrc
import os
import requests
import s3fs
urs = 'urs.earthdata.nasa.gov'
netrc_name = ".netrc"
netrcDir = os.path.expanduser(f"~/{netrc_name}")
netrc(netrcDir).authenticators(urs)[0]
gesdisc_s3 = "https://data.gesdisc.earthdata.nasa.gov/s3credentials"
def begin_s3_direct_access(url: str=gesdisc_s3):
response = requests.get(url).json()
return s3fs.S3FileSystem(key=response['accessKeyId'],
secret=response['secretAccessKey'],
token=response['sessionToken'],
client_kwargs={'region_name':'us-west-2'})
fs = begin_s3_direct_access()
fn = 's3://gesdisc-cumulus-prod-protected/GPM_L3/GPM_3IMERGHHE.06/2023/091/3B-HHR-E.MS.MRG.3IMERG.20230401-S000000-E002959.0000.V06C.HDF5'
fs.ls(fn)
However, upon running this code, I receive the following error message:
---------------------------------------------------------------------------
ClientError Traceback (most recent call last)
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/s3fs/core.py:113, in _error_wrapper(func, args, kwargs, retries)
112 try:
--> 113 return await func(*args, **kwargs)
114 except S3_RETRYABLE_ERRORS as e:
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/aiobotocore/client.py:383, in AioBaseClient._make_api_call(self, operation_name, api_params)
382 error_class = self.exceptions.from_code(error_code)
--> 383 raise error_class(parsed_response, operation_name)
384 else:
ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
The above exception was the direct cause of the following exception:
PermissionError Traceback (most recent call last)
/home/gabriel/notebooks/dsfc_nasa/open.py in line 38
35 # Files are organized by s3://gesdisc-cumulus-prod-protected/MERRA2/M2T1NXSLV.5.12.4/year/mo/*.nc4
37 fn = 's3://gesdisc-cumulus-prod-protected/GPM_L3/GPM_3IMERGHHE.06/2023/091/3B-HHR-E.MS.MRG.3IMERG.20230401-S000000-E002959.0000.V06C.HDF5'
---> 38 fs.info(fn)
File ~/notebooks/dsfc_nasa/.venv/lib/python3.10/site-packages/fsspec/asyn.py:118, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
115 @functools.wraps(func)
116 def wrapper(*args, **kwargs):
...
138 err = e
139 err = translate_boto_error(err)
--> 140 raise err
PermissionError: Forbidden
I'd greatly appreciate any guidance or suggestions to resolve this issue. I've reviewed my permissions in the site, followed the steps outlined in the documentation, and am confident I'm in the correct zone.
Thank you.