

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

# 管理 IAM 資源的政策範例
<a name="id_credentials_delegate-permissions_examples"></a>

以下 IAM 政策範例允許使用者執行與管理 IAM 使用者、群組和憑證相關的任務。這包括允許使用者管理自己的密碼、存取金鑰和多重要素驗證 (MFA) 裝置的政策。

如需允許使用者使用其他 AWS 服務執行任務的政策範例，例如 Amazon S3、Amazon EC2 和 DynamoDB，請參閱 [以身分為基礎的 IAM 政策範例](access_policies_examples.md)。

**Topics**
+ [允許使用者列出帳戶的群組、使用者、政策等，以供報告之用](#iampolicy-example-userlistall)
+ [允許使用者管理群組的成員資格](#iampolicy-example-usermanagegroups)
+ [允許使用者管理 IAM 使用者](#creds-policies-users)
+ [允許使用者設定帳戶密碼政策](#creds-policies-set-password-policy)
+ [允許使用者產生和擷取 IAM 憑證報告](#iampolicy-generate-credential-report)
+ [允許所有 IAM 動作 (管理員存取)](#creds-policies-all-iam)

## 允許使用者列出帳戶的群組、使用者、政策等，以供報告之用
<a name="iampolicy-example-userlistall"></a>

以下政策允許使用者呼叫以字串 `Get` 或 `List` 開頭的任何 IAM 動作來產生報告。若要檢視範例政策，請參閱 [IAM：允許對 IAM 主控台的唯讀存取權](reference_policies_examples_iam_read-only-console.md)。

## 允許使用者管理群組的成員資格
<a name="iampolicy-example-usermanagegroups"></a>

以下政策允許使用者更新名為 *MarketingGroup* 群組的成員資格。若要檢視範例政策，請參閱 [IAM：允許以程式設計方式及在主控台中管理群組的成員資格](reference_policies_examples_iam_manage-group-membership.md)。

## 允許使用者管理 IAM 使用者
<a name="creds-policies-users"></a>

以下政策允許使用者執行所有與管理 IAM 使用者相關的任務，但是不允許對其他實體執行操作，如建立群組或政策。允許的動作包括：
+ 建立使用者 ([https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateUser.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateUser.html) 動作)。
+ 刪除使用者。此任務需要許可以執行下列動作：[https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteSigningCertificate.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteSigningCertificate.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteLoginProfile.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteLoginProfile.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_RemoveUserFromGroup.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_RemoveUserFromGroup.html) 和 [https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUser.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUser.html)。
+ 列出帳戶和群組中的使用者 ([https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUsers.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUsers.html) 和 [https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListGroupsForUser.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListGroupsForUser.html) 動作)。
+ 列出並移除使用者的政策 ([https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUserPolicies.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListUserPolicies.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedUserPolicies.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedUserPolicies.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachUserPolicy.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachUserPolicy.html)、[https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUserPolicy.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUserPolicy.html) 動作) 
+ 更改或變更使用者路徑 ([https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateUser.html](https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateUser.html) 動作)。`Resource` 元素必須包含涵蓋來源路徑和目標路徑的 ARN。如需有關路徑的詳細資訊，請參閱 [易用名稱和路徑](reference_identifiers.md#identifiers-friendly-names)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowUsersToPerformUserActions",
            "Effect": "Allow",
            "Action": [
                "iam:ListPolicies",
                "iam:GetPolicy",
                "iam:UpdateUser",
                "iam:AttachUserPolicy",
                "iam:ListEntitiesForPolicy",
                "iam:DeleteUserPolicy",
                "iam:DeleteUser",
                "iam:ListUserPolicies",
                "iam:CreateUser",
                "iam:RemoveUserFromGroup",
                "iam:AddUserToGroup",
                "iam:GetUserPolicy",
                "iam:ListGroupsForUser",
                "iam:PutUserPolicy",
                "iam:ListAttachedUserPolicies",
                "iam:ListUsers",
                "iam:GetUser",
                "iam:DetachUserPolicy"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowUsersToSeeStatsOnIAMConsoleDashboard",
            "Effect": "Allow",
            "Action": [
                "iam:GetAccount*",
                "iam:ListAccount*"
            ],
            "Resource": "*"
        }
    ]
}
```

------

前述政策中包含的多個許可，允許使用者在 AWS 管理主控台中執行任務。從 [AWS CLI](https://aws.amazon.com/cli/)、[AWS 開發套件](https://aws.amazon.com/tools/)或 IAM HTTP 查詢 API 執行使用者相關任務的使用者可能不需要特定許可。例如，如果使用者已知道從使用者取消連接的 ARN，則不需要 `iam:ListAttachedUserPolicies` 許可。使用者所需許可的確切清單取決於使用者管理其他使用者時必須執行的任務。

以下政策中的許可允許透過 AWS 管理主控台存取使用者任務：
+ `iam:GetAccount*`
+ `iam:ListAccount*`

## 允許使用者設定帳戶密碼政策
<a name="creds-policies-set-password-policy"></a>

您可以授予某些使用者取得和更新您 AWS 帳戶[密碼政策](id_credentials_passwords_account-policy.md)的許可。若要檢視範例政策，請參閱 [IAM：允許以程式設計方式在主控台中設定帳戶密碼要求](reference_policies_examples_iam_set-account-pass-policy.md)。

## 允許使用者產生和擷取 IAM 憑證報告
<a name="iampolicy-generate-credential-report"></a>

您可以授予使用者許可，以產生和下載列出您 中所有使用者的報告 AWS 帳戶。此報告也會列出各種使用者憑證的狀態，包括密碼、存取金鑰、MFA 裝置和簽章憑證。如需有關憑證報告的詳細資訊，請參閱 [為您的 產生登入資料報告 AWS 帳戶](id_credentials_getting-report.md)。若要檢視範例政策，請參閱 [IAM：產生和擷取 IAM 憑證報告](reference_policies_examples_iam-credential-report.md)。

## 允許所有 IAM 動作 (管理員存取)
<a name="creds-policies-all-iam"></a>

您可以授予某些使用者在 IAM 中執行所有操作的管理員許可，包括管理密碼、存取金鑰、MFA 裝置和使用者憑證。以下範例政策授予這些許可。

**警告**  
當您授予使用者 IAM 的完全存取權時，對於使用者可以向自己或他人授予的許可則沒有限制。使用者可以建立新的 IAM 實體 (使用者或角色) 並授予這些實體對您 AWS 帳戶中所有資源的完全存取權限。您授予使用者對 IAM 的完全存取權限時，實際上是授予使用者對您的 AWS 帳戶中所有資源的完全存取權限。這包括可刪除所有資源的許可。您應只將這些許可授予信任的管理員，也應該對這些管理員強制採用多重要素驗證 (MFA)。

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

****  

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

------