

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用创建组织单位 (OU) Amazon Organizations
<a name="create_ou"></a>

登录组织的管理账户后，可以在组织的根目录中创建 OU。 OUs 最多可以嵌套五层。要创建 OU，请完成以下步骤。

**重要**  
如果使用管理此组织 Amazon Control Tower，则使用 Amazon Control Tower 控制台或创建您的 OUs 组织 APIs。如果您在 Organizations 中创建 OU，则该组织单位未在其中注册 Amazon Control Tower。有关更多信息，请参阅《Amazon Control Tower 用户指南》**中的[引用 Amazon Control Tower的外部资源](https://docs.amazonaws.cn/controltower/latest/userguide/external-resources.html#ungoverned-resources)。

**最小权限**  
要在组织的根中创建 OU，您必须拥有以下权限：  
`organizations:DescribeOrganization` – 仅当使用 Organizations 控制台时才需要
`organizations:CreateOrganizationalUnit`

## Amazon Web Services 管理控制台
<a name="create_ou_console"></a>

**创建 OU**

1. 登录 [Amazon Organizations 控制台](https://console.amazonaws.cn/organizations/v2)。您必须以 IAM 用户的身份登录，担任 IAM 角色；或在组织的管理账户中以根用户的身份登录（[不推荐](https://docs.amazonaws.cn/IAM/latest/UserGuide/best-practices.html#lock-away-credentials)）。

1. 导航到**[Amazon Web Services 账户](https://console.amazonaws.cn/organizations/v2/home/accounts)**页面。

   控制台会显示根 OU 及其内容。首次访问根时，控制台在该顶级视图中显示所有 Amazon Web Services 账户 。如果您之前创建了账户 OUs 并将其移入其中，则控制台将仅显示顶级账户 OUs 以及您尚未移入 OU 的所有账户。

1. （可选）如果要在现有 OU 内创建 OU，请通过选择[子 OU 的名称（不是复选框）来导航](navigate_tree.md)到子组织单位，或者 OUs 在树视图中选择![\[Gray cloud icon with an arrow pointing downward, indicating download or cloud storage.\]](http://docs.amazonaws.cn/organizations/latest/userguide/images/expand-icon.png)下一个组织单位，直到看到想要的 OU，然后选择其名称。

1. 在层次结构中选择了正确的父 OU 后，在 **Actions (操作)** 菜单上的 **Organizational Unit (组织部门)** 下，选择 **Create new (新建)**

1. 在 **Create organizational unit (创建组织部门)** 对话框中，键入要创建的 OU 的名称。

1. （可选）添加一个或多个标签，方法是选择 **Add tag (添加标签)**，然后输入一个键和可选的值。将值留空，设置为空字符串；它并非 `null`。您最多可以向 OU 附加 50 个标签。

1. 最后，选择 **Create organizational unit (创建组织部门)**。

您的新 OU 显示在父级内部。现在，您可以[将账户移动到此 OU](move_account_to_ou.md) 或者为其附加策略。

## Amazon CLI & Amazon SDKs
<a name="create_ou_cli_sdk"></a>

**创建 OU**

以下代码示例演示如何使用 `CreateOrganizationalUnit`。

------
#### [ .NET ]

**适用于 .NET 的 Amazon SDK**  
 还有更多相关信息 GitHub。在 [Amazon 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples)中查找完整示例，了解如何进行设置和运行。

```
    using System;
    using System.Threading.Tasks;
    using Amazon.Organizations;
    using Amazon.Organizations.Model;

    /// <summary>
    /// Creates a new organizational unit in AWS Organizations.
    /// </summary>
    public class CreateOrganizationalUnit
    {
        /// <summary>
        /// Initializes an Organizations client object and then uses it to call
        /// the CreateOrganizationalUnit method. If the call succeeds, it
        /// displays information about the new organizational unit.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var orgUnitName = "ProductDevelopmentUnit";

            var request = new CreateOrganizationalUnitRequest
            {
                Name = orgUnitName,
                ParentId = "r-0000",
            };

            var response = await client.CreateOrganizationalUnitAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"Successfully created organizational unit: {orgUnitName}.");
                Console.WriteLine($"Organizational unit {orgUnitName} Details");
                Console.WriteLine($"ARN: {response.OrganizationalUnit.Arn} Id: {response.OrganizationalUnit.Id}");
            }
            else
            {
                Console.WriteLine("Could not create new organizational unit.");
            }
        }
    }
```
+  有关 API 的详细信息，请参阅 *适用于 .NET 的 Amazon SDK API 参考[CreateOrganizationalUnit](https://docs.amazonaws.cn/goto/DotNetSDKV3/organizations-2016-11-28/CreateOrganizationalUnit)*中的。

------
#### [ CLI ]

**Amazon CLI**  
**在根 OU 或父 OU 中创建 OU**  
以下示例演示如何创建名为 AccountingOU 的 OU：  

```
aws organizations create-organizational-unit --parent-id r-examplerootid111 --name AccountingOU
```
输出包括一个 organizationalUnit 对象，其中包含有关新 OU 的详细信息：  

```
{
        "OrganizationalUnit": {
                "Id": "ou-examplerootid111-exampleouid111",
                "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111",
                "Name": "AccountingOU"
        }
}
```
+  有关 API 的详细信息，请参阅*Amazon CLI 命令参考[CreateOrganizationalUnit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-organizational-unit.html)*中的。

------