From 9c529b705e1302d86283bf8fe12d57550ebdcaa7 Mon Sep 17 00:00:00 2001 From: rodalarc Date: Tue, 22 Dec 2020 17:10:04 -0300 Subject: [PATCH 1/2] Add support for S3 Access Points (#393) --- awswrangler/_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awswrangler/_utils.py b/awswrangler/_utils.py index c9f0c8937..74416dcde 100644 --- a/awswrangler/_utils.py +++ b/awswrangler/_utils.py @@ -124,16 +124,20 @@ def parse_path(path: str) -> Tuple[str, str]: >>> from awswrangler._utils import parse_path >>> bucket, key = parse_path('s3://bucket/key') + >>> from awswrangler._utils import parse_path + >>> bucket, key = parse_path('s3://arn:aws:s3:::accesspoint//object/') """ if path.startswith("s3://") is False: raise exceptions.InvalidArgumentValue(f"'{path}' is not a valid path. It MUST start with 's3://'") - parts = path.replace("s3://", "").split("/", 1) + parts = path.replace("s3://", "").replace(":accesspoint/", ":accesspoint:").split("/", 1) bucket: str = parts[0] if "/" in bucket: raise exceptions.InvalidArgumentValue(f"'{bucket}' is not a valid bucket name.") key: str = "" if len(parts) == 2: key = key if parts[1] is None else parts[1] + if ":accesspoint:" in bucket: + key = key.replace("object/", "", 1) return bucket, key From c5900e1cecba0b0836f997d41a2bb2531963ede3 Mon Sep 17 00:00:00 2001 From: rodalarc Date: Tue, 22 Dec 2020 18:44:17 -0300 Subject: [PATCH 2/2] Add support for S3 Access Points (#393) --- awswrangler/_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/awswrangler/_utils.py b/awswrangler/_utils.py index 74416dcde..7e4141a1b 100644 --- a/awswrangler/_utils.py +++ b/awswrangler/_utils.py @@ -125,7 +125,7 @@ def parse_path(path: str) -> Tuple[str, str]: >>> bucket, key = parse_path('s3://bucket/key') >>> from awswrangler._utils import parse_path - >>> bucket, key = parse_path('s3://arn:aws:s3:::accesspoint//object/') + >>> bucket, key = parse_path('s3://arn:aws:s3:::accesspoint//') """ if path.startswith("s3://") is False: raise exceptions.InvalidArgumentValue(f"'{path}' is not a valid path. It MUST start with 's3://'") @@ -136,8 +136,6 @@ def parse_path(path: str) -> Tuple[str, str]: key: str = "" if len(parts) == 2: key = key if parts[1] is None else parts[1] - if ":accesspoint:" in bucket: - key = key.replace("object/", "", 1) return bucket, key