import boto3
s3 = boto3.client('s3') bucket_name = 'your_bucket_name'
try: response = s3.get_object(Bucket=bucket_name, Key='your_key_here') print(response['Body'].read().decode('utf-8')) except Exception as e: print(e)
确保您使用的IAM用户或角色拥有以下权限。
s3:ListBucket s3:GetObject
通过执行以上步骤,您应该能够解决“AWS - S3访问被拒绝”的CloudWatch日志异常。
下一篇:AWS-S3路径权限被拒绝