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.

feita há 4 meses170 visualizações
Sem respostas

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas