S3 Express One Zone: no such bucket

0

I created a directory-type bucket at S3 Express One Zone and am trying to get an object from it from a AWS Lambda function. Both are in the same us-east-1 region. My function is based on the example from the documentation:

import boto3
import json

def get_object(s3_client, bucket_name, key_name):
    try:
        response = s3_client.get_object(Bucket=bucket_name, Key=key_name)
        body = response['Body'].read()
        print(f"Got object '{key_name}' from bucket '{bucket_name}'.")
        return body
    except:
        print(f"Couldn't get object '{key_name}' from bucket '{bucket_name}'.")
        raise

def lambda_handler(event, context):
    s3_client = boto3.client('s3')
    resp = get_object(s3_client, 'mybucket--use1-az4--x-s3', 'myobject')
    return {'statusCode': 200}

I get an exception at calling get_object:

An error occurred (NoSuchBucket) when calling the GetObject operation: The specified bucket does not exist.

If I use the name of a regular (non-directory) bucket, it works. So it is not a permissions problem.

I thought that may be I am using the version of boto3 that does not support the new bucket type. So, I created the Lambda function anew (Python 3.10 environment), but still get the same result.

What am I missing?

UPDATE: Adding a layer with the latest boto3 resolved the issue.

  • Glad you found a solution! Please add your own Answer to help future readers.

已提問 9 個月前檢視次數 197 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南