调用 HeadObject 操作时发生客户端错误 (400):Bad Request Completed 1 part(s) with ... file(s) remaining
A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining
我正在尝试通过 cli 将文件从私有 s3 存储桶复制到我的 ec2 实例。 ec2 与存储桶位于同一区域,并附加了以下 IAM 角色 (AmazonS3FullAccess):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
但是命令 aws s3 cp s3://[BUCKETNAME]/index.html
失败并显示错误:
A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining.
我已经仔细检查了存储桶名称的拼写...
当我将相同的政策从 "inline policies" 更改为 "managed policies" 时,它起作用了。在
参考我的回答
我在语句中添加了 --region 选项,现在一切正常:
aws s3 cp s3:/[BUCKETNAME]/ . --recursive --region [REGION]
我升级到最新版本的 aws cli 后,我的问题就得到了解决。以下是升级方式:
pip install --upgrade --user awscli
指定区域没有帮助
--region
参数对我不起作用。
我尝试使用 --profile
,一切正常。
aws s3api head-bucket --bucket xxxx --profile dev-profile
如果您的会话已过期,如果使用具有假定角色的临时安全凭证,也会发生此错误。不像您期望的那样是禁止的或未知的 ID。
对我来说,问题是我在我的 AWS 配置文件 (~/.aws/config
) 中将 use_accelerate_endpoint
设置为 true。将其更改为 false 解决了这个问题。这是我的配置文件现在的样子:
[default]
region = us-west-2
output = json
s3 =
use_accelerate_endpoint = false
我正在尝试通过 cli 将文件从私有 s3 存储桶复制到我的 ec2 实例。 ec2 与存储桶位于同一区域,并附加了以下 IAM 角色 (AmazonS3FullAccess):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
但是命令 aws s3 cp s3://[BUCKETNAME]/index.html
失败并显示错误:
A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining.
我已经仔细检查了存储桶名称的拼写...
当我将相同的政策从 "inline policies" 更改为 "managed policies" 时,它起作用了。在
我在语句中添加了 --region 选项,现在一切正常:
aws s3 cp s3:/[BUCKETNAME]/ . --recursive --region [REGION]
我升级到最新版本的 aws cli 后,我的问题就得到了解决。以下是升级方式:
pip install --upgrade --user awscli
指定区域没有帮助
--region
参数对我不起作用。
我尝试使用 --profile
,一切正常。
aws s3api head-bucket --bucket xxxx --profile dev-profile
如果您的会话已过期,如果使用具有假定角色的临时安全凭证,也会发生此错误。不像您期望的那样是禁止的或未知的 ID。
对我来说,问题是我在我的 AWS 配置文件 (~/.aws/config
) 中将 use_accelerate_endpoint
设置为 true。将其更改为 false 解决了这个问题。这是我的配置文件现在的样子:
[default]
region = us-west-2
output = json
s3 =
use_accelerate_endpoint = false