

我們不再更新 Amazon Machine Learning 服務或接受新使用者。本文件可供現有使用者使用，但我們不再更新。如需詳細資訊，請參閱[什麼是 Amazon Machine Learning](https://docs.aws.amazon.com/machine-learning/latest/dg/what-is-amazon-machine-learning.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 授予 Amazon ML 將預測輸出至 Amazon S3 的許可
<a name="granting-amazon-ml-permissions-to-output-predictions-to-amazon-s3"></a>

 若要將批次預測操作的結果輸出至 Amazon S3，必須就「建立批次預測」操作時提供做為輸入的輸出位置授予 Amazon ML 以下許可：
+  您的 S3 儲存貯體與字首的 **GetObject** 許可。
+  您的 S3 儲存貯體與字首的 **PutObject** 許可。
+  您的 S3 儲存貯體與字首的 **PutObjectAcl** 許可。
  +  Amazon ML 需要此許可，以確保在建立物件之後可將標準 [ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) 儲存貯體擁有者完整控制許可授予您的 AWS 帳戶。
+  S3 儲存貯體上的 **ListBucket** 許可。不同於其他動作，必須將儲存貯體範圍的許可 (而不是字首) 授予 **ListBucket**。不過，您可以使用 **Condition** 子句，將許可範圍限定為特定字首。

 若使用 Amazon ML 主控台建立批次預測請求，可以將這些許可新增到您的儲存貯體。當您完成精靈中的步驟時，會提示您確認是否要新增這些許可。

 以下範例政策示範如何授予許可，讓 Amazon ML 可將資料寫入範例位置 s3://examplebucket/exampleprefix，並將 **ListBucket** 許可範圍侷限在 exampleprefix 輸入路徑，以及授予 Amazon ML 對輸出字首設定放置物件 ACL 的許可：

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "machinelearning.amazonaws.com"
            },
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::examplebucket/exampleprefix/*",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:machinelearning:us-east-1:123456789012:*"
                }
            }
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "machinelearning.amazonaws.com"
            },
            "Action": "s3:PutObjectAcl",
            "Resource": "arn:aws:s3:::examplebucket/exampleprefix/*",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:machinelearning:us-east-1:123456789012:*"
                }
            }
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "machinelearning.amazonaws.com"
            },
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::examplebucket",
            "Condition": {
                "StringLike": {
                    "s3:prefix": "exampleprefix/*"
                },
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:machinelearning:us-east-1:123456789012:*"
                }
            }
        }
    ]
}
```

------

若要將此政策套用到您的資料，您必須編輯與您存放資料之 S3 儲存貯體相關聯的政策陳述式。

**編輯 S3 儲存貯體的許可政策 (使用舊版主控台)**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 開啟 Amazon S3 主控台。

1. 選取您資料所在的儲存貯體名稱。

1. 選擇 **Properties (屬性)**。

1. 選擇 **Edit bucket policy (編輯儲存貯體政策)**。

1. 輸入上述政策，並依照您的需求加以自訂，然後選擇 **Save (儲存)**。

1. 選擇**儲存**。



**編輯 S3 儲存貯體的許可政策 (使用新版主控台)**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 開啟 Amazon S3 主控台。

1. 選擇儲存貯體名稱，然後選擇 **Permissions (許可)**。

1. 選擇 **Bucket Policy** (儲存貯體政策)。

1. 輸入上述政策，並加以自訂以符合您的需求。

1. 選擇**儲存**。