

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

# 在 Snowball Edge 上本機使用 IAM
<a name="using-local-iam"></a>

AWS Identity and Access Management (IAM) 可協助您安全地控制對 AWS Snowball 邊緣 裝置上執行之 AWS 資源的存取。您可以使用 IAM 來控制能通過身分驗證 (登入) 和授權使用資源的 (具有許可) 的人員。

在您的裝置本機支援 IAM。您可以使用本機 IAM 服務來建立新的使用者，並將 IAM 政策連接到他們。您可以使用這些政策來允許執行指派任務所需的存取權。例如，您可以讓使用者能夠傳輸資料，但限制他們建立新的 Amazon EC2-compatible執行個體的能力。

此外，您可以在裝置上使用 AWS Security Token Service (AWS STS) 建立本機工作階段型登入資料。如需 IAM 服務的資訊，請參閱《*IAM 使用者指南*》中的[入門](https://docs.aws.amazon.com/IAM/latest/GettingStartedGuide/)。

您裝置的根登入資料無法停用，而且您無法使用帳戶中的政策明確拒絕存取 AWS 帳戶 根使用者。我們建議您保護根使用者存取金鑰，並建立 IAM 使用者登入資料，以便與裝置進行日常互動。

**重要**  
本節中的文件適用於在 AWS Snowball 邊緣 本機裝置上使用 IAM。如需在 中使用 IAM 的詳細資訊 AWS 雲端，請參閱 [中的 Identity and Access Management AWS Snowball Edge](snowball-edge-iam.md)。  
若要讓 AWS 服務在 Snowball Edge 上正常運作，您必須允許服務的連接埠。如需詳細資訊，請參閱[Snowball Edge 上 AWS 服務的連接埠需求](port-requirements.md)。

**Topics**
+ [在 Snowball Edge 上使用 AWS CLI 和 API 操作](#local-iam-specify-region)
+ [Snowball Edge 上支援的 IAM AWS CLI 命令清單](#local-iam-cli-commands)
+ [Snowball Edge 上的 IAM 政策範例](#policy-examples)
+ [Snowball Edge 上的 TrustPolicy 範例](#role-policy-example-trust)

## 在 Snowball Edge 上使用 AWS CLI 和 API 操作
<a name="local-iam-specify-region"></a>

使用 AWS CLI 或 API 操作在 Snowball Edge 上發出 IAM AWS STS、Amazon S3 和 Amazon EC2 命令時，您必須將 指定`region`為「」`snow`。 您可以使用 `aws configure` 或在命令本身內執行此操作，如下列範例所示。

```
aws configure --profile abc
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: 1234567
Default region name [None]: snow
Default output format [None]: json
```

或

```
aws iam list-users --endpoint http://192.0.2.0:6078 --region snow --profile snowballEdge 
```

**注意**  
在 上 AWS Snowball 邊緣 本機使用的存取金鑰 ID 和存取私密金鑰無法與 中的金鑰交換 AWS 雲端。

## Snowball Edge 上支援的 IAM AWS CLI 命令清單
<a name="local-iam-cli-commands"></a>

以下是 Snowball Edge 裝置上支援的 IAM AWS CLI 命令和選項子集的描述。如果某命令或選項未在以下列出，則不受支援。命令不支援的參數會在描述中註明。
+ [attach-role-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/attach-role-policy.html) – 將指定的受管政策連接至指定的 IAM 角色。
+ [attach-user-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/attach-user-policy.html) – 將指定的受管政策連接至指定的使用者。
+ [create-access-key](https://docs.aws.amazon.com/cli/latest/reference/iam/create-access-key.html) – 為指定的使用者建立新的本機 IAM 私密存取金鑰和對應的 AWS 存取金鑰 ID。
+ [create-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/create-policy.html) – 為您的裝置建立新的 IAM 受管政策。
+ [create-role](https://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html) – 為您的裝置建立新的本機 IAM 角色。**不**支援下列參數：
  + `Tags`
  + `PermissionsBoundary`
+ [create-user](https://docs.aws.amazon.com/cli/latest/reference/iam/create-user.html) – 為您的裝置建立新的本機 IAM 使用者。**不**支援下列參數：
  + `Tags`
  + `PermissionsBoundary`
+ [delete-access-key](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-access-key.html) – 刪除指定使用者的新本機 IAM 私密存取金鑰和對應的 AWS 存取金鑰 ID。
+ [delete-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-policy.html) – 刪除指定的受管政策。
+ [delete-role](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-role.html) – 刪除指定的角色。
+ [delete-user](https://docs.aws.amazon.com/cli/latest/reference/iam/delete-user.html) – 刪除指定的使用者。
+ [detach-role-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/detach-role-policy.html) – 從指定的角色移除指定的受管政策。
+ [detach-user-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/detach-user-policy.html) – 從指定的使用者移除指定的受管政策。
+ [get-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/get-policy.html) – 擷取指定受管政策的相關資訊，包括政策的預設版本，以及附加政策的本機 IAM 使用者、群組和角色總數。
+ [get-policy-version](https://docs.aws.amazon.com/cli/latest/reference/iam/get-policy-version.html) – 擷取指定受管政策指定版本的相關資訊，包括政策文件。
+ [get-role](https://docs.aws.amazon.com/cli/latest/reference/iam/get-role.html) – 擷取指定角色的相關資訊，包括角色的路徑、GUID、ARN，以及授予擔任角色許可的角色信任政策。
+ [get-user](https://docs.aws.amazon.com/cli/latest/reference/iam/get-user.html) – 擷取指定 IAM 使用者的相關資訊，包括使用者的建立日期、路徑、唯一 ID 和 ARN。
+ [list-access-keys](https://docs.aws.amazon.com/cli/latest/reference/iam/list-access-keys.html) – 傳回與指定 IAM 使用者相關聯之存取金鑰 IDs 的相關資訊。
+ [list-attached-role-policies](https://docs.aws.amazon.com/cli/latest/reference/iam/list-attached-role-policies.html) – 列出連接至指定 IAM 角色的所有受管政策。
+ [list-attached-user-policies](https://docs.aws.amazon.com/cli/latest/reference/iam/list-attached-user-policies.html) – 列出連接至指定 IAM 使用者的所有受管政策。
+ [list-entities-for-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/list-entities-for-policy.html) – 列出指定受管政策連接的所有本機 IAM 使用者、群組和角色。
  + `--EntityFilter`：僅支援 `user` 和 `role` 值。
+ [list-policies](https://docs.aws.amazon.com/cli/latest/reference/iam/list-policies.html) – 列出您本機中提供的所有受管政策 AWS 帳戶。**不**支援下列參數：
  + `--PolicyUsageFilter`
+ [list-roles](https://docs.aws.amazon.com/cli/latest/reference/iam/list-roles.html) – 列出具有指定路徑字首的本機 IAM 角色。
+ [list-users](https://docs.aws.amazon.com/cli/latest/reference/iam/list-users.html) – 列出具有指定路徑字首的 IAM 使用者。
+ [update-access-key](https://docs.aws.amazon.com/cli/latest/reference/iam/update-access-key.html) – 將指定存取金鑰的狀態從作用中變更為非作用中，反之亦然。
+ [update-assume-role-policy](https://docs.aws.amazon.com/cli/latest/reference/iam/update-assume-role-policy.html) – 更新授予 IAM 實體擔任角色許可的政策。
+ [update-role](https://docs.aws.amazon.com/cli/latest/reference/iam/update-role.html) – 更新角色的描述或工作階段持續時間上限設定。
+ [update-user](https://docs.aws.amazon.com/cli/latest/reference/iam/update-user.html) – 更新指定 IAM 使用者的名稱和/或路徑。

### Snowball Edge 上支援的 IAM API 操作
<a name="iam-local-supported-apis"></a>

以下是您可以搭配 Snowball Edge 使用的 IAM API 操作，其中包含 IAM API 參考中其描述的連結。
+ [AttachRolePolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_AttachRolePolicy.html) – 將指定的受管政策連接至指定的 IAM 角色。
+ [AttachUserPolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_AttachUserPolicy.html) – 將指定的受管政策連接至指定的使用者。
+ [CreateAccessKey](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html) – 為指定的使用者建立新的本機 IAM 私密存取金鑰和對應的 AWS 存取金鑰 ID。
+ [CreatePolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicy.html) – 為您的裝置建立新的 IAM 受管政策。
+ [CreateRole](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateRole.html) – 為您的裝置建立新的本機 IAM 角色。
+ [CreateUser](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateUser.html) – 為您的裝置建立新的本機 IAM 使用者。

  **不**支援下列參數：
  + `Tags`
  + `PermissionsBoundary`
+ [DeleteAccessKey](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteAccessKey.html) – 刪除指定的存取金鑰。
+ [DeletePolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeletePolicy.html) – 刪除指定的受管政策。
+ [DeleteRole](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteRole.html) – 刪除指定的角色。
+ [DeleteUser](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUser.html) – 刪除指定的使用者。
+ [DetachRolePolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachRolePolicy.html) – 從指定的角色移除指定的受管政策。
+ [DetachUserPolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachUserPolicy.html) – 從指定的使用者移除指定的受管政策。
+ [GetPolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetPolicy.html) – 擷取指定受管政策的相關資訊，包括政策的預設版本，以及附加政策的本機 IAM 使用者、群組和角色總數。
+ [GetPolicyVersion](https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetPolicyVersion.html) – 擷取指定受管政策指定版本的相關資訊，包括政策文件。
+ [GetRole](https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetRole.html) – 擷取指定角色的相關資訊，包括角色的路徑、GUID、ARN，以及授予擔任角色許可的角色信任政策。
+ [GetUser](https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html) – 擷取指定 IAM 使用者的相關資訊，包括使用者的建立日期、路徑、唯一 ID 和 ARN。
+ [ListAccessKeys](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAccessKeys.html) – 傳回與指定 IAM 使用者相關聯之存取金鑰 IDs 的相關資訊。
+ [ListAttachedRolePolicies](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedRolePolicies.html) – 列出連接至指定 IAM 角色的所有受管政策。
+ [ListAttachedUserPolicies](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedUserPolicies.html) – 列出連接至指定 IAM 使用者的所有受管政策。
+ [ListEntitiesForPolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListEntitiesForPolicy.html) – 擷取指定 IAM 使用者的相關資訊，包括使用者的建立日期、路徑、唯一 ID 和 ARN。
  + `--EntityFilter`：僅支援 `user` 和 `role` 值。
+ [ListPolicies](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicies.html) – 列出本機 中提供的所有受管政策 AWS 帳戶。**不**支援下列參數：
  + `--PolicyUsageFilter`
+ [ListRoles](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListRoles.html) – 列出具有指定路徑字首的本機 IAM 角色。
+ [ListUsers](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUsers.html) – 列出具有指定路徑字首的 IAM 使用者。
+ [UpdateAccessKey](https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateAccessKey.html) – 將指定存取金鑰的狀態從作用中變更為非作用中，反之亦然。
+ [UpdateAssumeRolePolicy](https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateAssumeRolePolicy.html) – 更新授予 IAM 實體擔任角色許可的政策。
+ [UpdateRole](https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateRole.html) – 更新角色的描述或工作階段持續時間上限設定。
+ [UpdateUser](https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateUser.html) – 更新指定 IAM 使用者的名稱和/或路徑。

### Snowball Edge 上支援的 IAM 政策版本和文法
<a name="iam-policy"></a>

以下是 IAM 政策的本機 IAM 支援版本 2012-10-17 和政策文法的子集。


| Policy type (政策類型) | 支援的文法 | 
| --- | --- | 
| 以身分為基礎的政策 (使用者/角色政策) | "Effect"、"Action" 和 "Resource" 本機 IAM 不支援 "`Condition`"、"`NotAction`"、"`NotResource`" 和 "`Principal`"。   | 
| 以資源為基礎的政策 (角色信任政策) | "Effect"、"Action" 和 "Principal" 對於主體，僅允許 AWS 帳戶 ID 或主體 ID。   | 

## Snowball Edge 上的 IAM 政策範例
<a name="policy-examples"></a>

**注意**  
AWS Identity and Access Management (IAM) 使用者需要`"snowballdevice:*"`許可才能使用[AWS OpsHub for Snow Family 應用程式](aws-opshub.md)來管理 Snowball Edge。

以下是授予 Snowball Edge 裝置許可的政策範例。

### 允許透過 IAM API 在 Snowball Edge 上對範例使用者進行 GetUser 呼叫
<a name="role-policy-example-iam"></a>

使用下列政策允許範例使用者透過 IAM API 呼叫 GetUser。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "iam:GetUser",
            "Resource": "arn:aws:iam:::user/example-user"
        }
    ]
}
```

------

### 允許完整存取 Snowball Edge 上的 Amazon S3 API
<a name="role-policy-example-s3-full"></a>

使用下列政策允許完整存取 Amazon S3 API。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": "*"
            
        }
    ]
}
```

------

### 允許對 Snowball Edge 上的 Amazon S3 儲存貯體進行讀取和寫入存取
<a name="role-policy-example-s3-bucket"></a>

 使用下列政策允許對特定儲存貯體的讀取和寫入存取權。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ListObjectsInBucket",
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::bucket-name"
        },
        {
            "Sid": "AllObjectActions",
            "Effect": "Allow",
            "Action": "s3:*Object",
            "Resource": "arn:aws:s3:::bucket-name/*"
        }
    ]
}
```

------<a name="role-policy-example-s3-list"></a>

### 允許在 Snowball Edge 上列出、取得和放置對 Amazon S3 儲存貯體的存取權
<a name="role-policy-example-s3-lgp"></a>

使用下列政策允許清單、取得和放置特定 S3 儲存貯體的存取權。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:List*"
            ],
            "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
        }
    ]
}
```

------

### 允許完整存取 Snowball Edge 上的 Amazon EC2 API
<a name="role-policy-example-ec2"></a>

 使用下列政策允許完整存取 Amazon EC2。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ec2:*",
            "Resource": "*"
        }
    ]
}
```

------

### 允許存取啟動和停止 Snowball Edge 上的 EC2-compatible執行個體
<a name="role-policy-example-ec2-stop-start"></a>

 使用下列政策允許啟動和停止 Amazon EC2 執行個體的存取權。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:StartInstances",
                "ec2:StopInstances"
            ],
            "Resource": "*"
        }
    ]
}
```

------

### 拒絕對 DescribeLaunchTemplates 的呼叫，但允許對 Snowball Edge 上的 DescribeImages 的所有呼叫
<a name="role-policy-example-ec2-desc-image"></a>

 使用下列政策拒絕對 `DescribeLaunchTemplates` 的呼叫，但允許對 `DescribeImages` 的所有呼叫。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Deny",
            "Action": [
                "ec2:DescribeLaunchTemplates"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeImages"
            ],
            "Resource": "*"
        }
    ]
}
```

------

### Snowball Edge 上的 API 呼叫政策
<a name="local-sts-cli-example-policy"></a>

列出 Snow 裝置上可用的所有受管政策，包括您自己的客戶定義受管政策。list[-policies](https://docs.aws.amazon.com/cli/latest/reference/iam/list-policies.html) 中的更多詳細資訊。

```
aws iam list-policies --endpoint http://ip-address:6078 --region snow --profile snowballEdge
{
    "Policies": [
        {
            "PolicyName": "Administrator",
            "Description": "Root user admin policy for Account 123456789012",
            "CreateDate": "2020-03-04T17:44:59.412Z",
            "AttachmentCount": 1,
            "IsAttachable": true,
            "PolicyId": "policy-id",
            "DefaultVersionId": "v1",
            "Path": "/",
            "Arn": "arn:aws:iam::123456789012:policy/Administrator",
            "UpdateDate": "2020-03-04T19:10:45.620Z"
        }
    ]
}
```

## Snowball Edge 上的 TrustPolicy 範例
<a name="role-policy-example-trust"></a>

信任政策會傳回一組臨時安全登入資料，您可以使用這些登入資料來存取您通常無法存取 AWS 的資源。這些臨時登入資料由存取金鑰 ID、私密存取金鑰和安全字符組成。通常，您可以在帳戶中使用 `AssumeRole` 進行跨帳戶存取。

下列是信任政策的範例。如需信任政策的詳細資訊，請參閱 *AWS Security Token Service API 參考*中的 [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html)。

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

****  

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::AccountId:root" //You can use the Principal ID instead of the account ID. 
                ]
            },
            "Action": [
                "sts:AssumeRole"
            ]
        }
    ]
}
```

------