首页 > 解决方案 > 使用 Boto3 列出具有访问点的 S3 存储桶对象

问题描述

我正在尝试使用list_objects_v2Python3 Boto3 S3 API 客户端的功能来列出来自 S3 接入点的对象。

示例代码:

import boto3
import botocore

access_point_arn = "arn:aws:s3:region:account-id:accesspoint/resource"
client = boto3.client('s3')
response = client.list_objects_v2(Bucket=access_point_arn)

不知何故得到以下错误:

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid bucket name "arn:aws:s3:region:account-id:accesspoint/resource": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"

根据文档:https ://docs.aws.amazon.com/AmazonS3/latest/dev/using-access-points.html ,我应该能够将访问点list_objects_v2作为存储桶名称传递给函数。奇怪的是,这个功能在我的 Windows 10 笔记本电脑上本地运行。具有相同 Boto3 和 Botocore 包版本的相同 Python3.6 代码会在 AWS Glue Python Shell 作业中引发此错误。我还确保 Glue 角色附加了 S3 完全访问权限和 Glue 服务策略。

如果有人能对此有所了解,我将不胜感激。

标签: pythonamazon-s3boto3aws-glueamazon-s3-access-points

解决方案


推荐阅读