AWS CreateDeviceFleet 操作失败,因为 "the account id does not have ownership on bucket"

AWS CreateDeviceFleet operation fail because "the account id does not have ownership on bucket"

我在尝试使用 sagemaker 创建设备队列时遇到 AWS 问题:

import boto3

sagemaker_client = boto3.client('sagemaker', region_name=AWS_REGION)
sagemaker_client.create_device_fleet(
    DeviceFleetName=device_fleet_name,
    RoleArn=iot_role_arn,
    OutputConfig={
        'S3OutputLocation': s3_device_fleet_output
    }
)

它引发了以下异常:

ClientError: An error occurred (ValidationException) when calling the CreateDeviceFleet operation: The account id <my-account-id> does not have ownership on bucket: <bucket-name>

我不明白,因为我创建了存储桶,所以我应该是所有者。我还没有找到如何检查或更改存储桶所有权的方法。

我尝试如下更改存储桶策略,但没有帮助。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Principal": {
                "AWS": "arn:aws:iam::<id>:user/<user>"
            },
            "Effect": "Allow",
            "Action": "*",
            "Resource": [
                "arn:aws:s3:::<bucket-name>",
                "arn:aws:s3:::<bucket-name>/*"
            ]
        }
    ]
}

我也尝试过使用 sagemaker 的 GUI,它因同样的原因而失败(ValidationException,帐户 ID 没有存储桶的所有权:)。

这个存储桶策略使它起作用:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<account-id>:role/<iot-role>"
            },
            "Action": "*",
            "Resource": [
                "arn:aws:s3:::<bucket-name>",
                "arn:aws:s3:::<bucket-name>/*"
            ]
        }
    ]
}

我还是不完全明白,因为该角色对 s3 存储桶具有完全访问权限,所以我不知道为什么编辑存储桶的策略会改变一些东西,但它有效。