BUG: no access to S3 Express One Zone (aka directory buckets) from AWS Lambda

0

Accessing buckets in S3 Express One Zone (aka directory buckets) from AWS Lamba function is not working. My Lambda 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 Exception as e:
        print(str(e))
        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.

The issue has been corroborated at SO.

질문됨 일 년 전705회 조회
1개 답변
1
수락된 답변

What version of boto3 are you using? You have have to create a ZIP file which includes the latest version of the library in order to access S3 Express One Zone.

Ref: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

profile pictureAWS
전문가
답변함 일 년 전
  • I created a new Lambda function with the latest Python environment and used boto3 bundled with it... I searched to find out which version of boto3 is required, but did not find anything...

  • The current version is 1.27.1. I will try to make a layer with the latest version.

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

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

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