You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用gsutil复制Amazon S3文件遇Access Denied,aws s3 cp可正常运行

S3到GCS复制时出现Access Denied错误的排查求助

尝试将文件从Amazon S3存储桶复制到Google Cloud Storage(GCS)存储桶时,遭遇Access Denied(403)错误。将操作拆分为两步测试:从S3复制到本地机器,同样失败。

执行命令:

gsutil -D cp s3://my-bucket/filename.txt ./test-copy

返回错误:

gslib.cloud_api.AccessDeniedException: AccessDeniedException: 403 AccessDenied
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>**REDACTED**</RequestId><HostId>**REDACTED**bc=</HostId></Error>

已尝试的解决方法:

  • 更换为拥有S3存储桶完整权限的AWS Access密钥
  • 执行aws s3 cp s3://my-bucket/filename.txt ./test-copy可正常运行,说明AWS侧无权限问题
  • 检查当前gcloud配置,确认配置正确,且已为GCS存储桶添加Storage Admin权限

通过aws s3 cp正常复制可证明AWS密钥权限无误,推测问题可能出在Python/gsutil版本上,本地环境版本如下:

  • gsutil版本:5.20
  • Python版本:3.10.8

以下是更多DEBUG日志片段:

Zero length chunk ignored
reply: 'HTTP/1.1 403 Forbidden\r\n'
header: x-amz-request-id: **REDACTED**
header: x-amz-id-2: **REDACTED**
header: Content-Type: application/xml
header: Transfer-Encoding: chunked
header: Date: Tue, 07 Mar 2023 15:35:40 GMT
header: Server: AmazonS3
DEBUG 0307 15:35:41.384847 connection.py] Response headers: [('x-amz-request-id', '**REDACTED**'), ('x-amz-id-2', '**REDACTED**'), ('Content-Type', 'application/xml'), ('Transfer-Encoding', 'chunked'), ('Date', 'Tue, 07 Mar 2023 15:35:40 GMT'), ('Server', 'AmazonS3')]
DEBUG: Exception stack trace:
    Traceback (most recent call last):
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/boto_translation.py", line 718, in _PerformResumableDownload
        key.get_file(fp,
    TypeError: Key.get_file() got an unexpected keyword argument 'hash_algs'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/boto_translation.py", line 590, in GetObjectMedia
        self._PerformResumableDownload(download_stream,
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/boto_translation.py", line 725, in _PerformResumableDownload
        key.get_file(fp,
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/s3/key.py", line 1500, in get_file
        self._get_file_internal(fp, headers=headers, cb=cb, num_cb=num_cb,
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/s3/key.py", line 1536, in _get_file_internal
        self.open('r', headers, query_args=query_args,
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/s3/key.py", line 357, in open
        self.open_read(headers=headers, query_args=query_args,
      File "/Users/**REDACTED**/Documents/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/s3/key.py", line 317, in open_read
        raise provider.storage_response_error(self.resp.status,
    boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
    <?xml version="1.0" encoding="UTF-8"?>
    <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>**REDACTED**</RequestId><HostId>**REDACTED**</HostId></Error>

内容的提问来源于stack exchange,提问作者sc-leeds

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 09:07:50