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.

asked 5 months ago178 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions