From 9bf33f78fe56c0189d86ed249a75c2660dda7ae9 Mon Sep 17 00:00:00 2001 From: Luke Muther <80649402+lmuther8@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:32:21 -0400 Subject: [PATCH 1/2] Proper upload_to_s3 error messaging --- zappa/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zappa/core.py b/zappa/core.py index f71134f16..6556b8d23 100644 --- a/zappa/core.py +++ b/zappa/core.py @@ -973,6 +973,10 @@ def upload_to_s3(self, source_path, bucket_name, disable_progress=False): try: self.s3_client.head_bucket(Bucket=bucket_name) except botocore.exceptions.ClientError: + # https://github.com/zappa/Zappa/issues/1315 + # 403 means bucket exists but the user does not have access + if e.response['Error']['Code'] == '403': + raise Exception(f'AWS Error: {e}. On bucket: {bucket_name}. This is likely an AWS permission issue, try adding s3:ListBucket to the deploying user or role.') # This is really stupid S3 quirk. Technically, us-east-1 one has no S3, # it's actually "US Standard", or something. # More here: https://github.com/boto/boto3/issues/125 From 9f915ab39266b2f5f59d49d9a3de7d5b0a5f8f6d Mon Sep 17 00:00:00 2001 From: Luke Muther <80649402+lmuther8@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:49:59 -0400 Subject: [PATCH 2/2] Update core.py Forgot to alias exception as e --- zappa/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zappa/core.py b/zappa/core.py index 6556b8d23..ae0588129 100644 --- a/zappa/core.py +++ b/zappa/core.py @@ -972,7 +972,7 @@ def upload_to_s3(self, source_path, bucket_name, disable_progress=False): """ try: self.s3_client.head_bucket(Bucket=bucket_name) - except botocore.exceptions.ClientError: + except botocore.exceptions.ClientError as e: # https://github.com/zappa/Zappa/issues/1315 # 403 means bucket exists but the user does not have access if e.response['Error']['Code'] == '403':