

我們不再更新 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-read-your-data-from-amazon-s3"></a>

 若要從您在 Amazon S3 中的輸入資料建立資料來源物件，必須將下列您存放輸入資料之 S3 位置的許可授予 Amazon ML：
+  S3 儲存貯體上的 **GetObject** 許可與字首。
+  S3 儲存貯體上的 **ListBucket** 許可。不同於其他動作，必須將儲存貯體範圍的許可 (而不是字首) 授予 **ListBucket**。不過，您可以使用 **Condition** 子句，將許可範圍限制為特定字首。

 如果您使用 Amazon ML 主控台來建立資料來源，則可為您將這些許可新增至儲存貯體。在您完成精靈的各步驟時，系統會提示您確認是否要新增許可。以下政策範例示範如何授予許可，讓 Amazon ML 從範例位置 s3://{{examplebucket}}/{{exampleprefix}} 讀取資料，同時限制 **ListBucket** 許可的範圍只在 {{exampleprefix}} 輸入路徑。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "machinelearning.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "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://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://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)：// 開啟 Amazon S3 主控台。

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

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

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

1. 選擇**儲存**。