S3 Express One Zone: no such bucket


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):
        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
        print(f"Couldn't get object '{key_name}' from bucket '{bucket_name}'.")

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.

질문됨 5달 전173회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠