Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用创建组织单位 (OU) Amazon Organizations
登录到组织的管理账户时,您可以在组织的根下创建 OU。OU 最深可嵌套至 5 层。要创建 OU,请完成以下步骤。
如果使用管理此组织 Amazon Control Tower,则使用 Amazon Control Tower 控制台或 API 创建您的 OU。如果您在 Organizations 中创建 OU,则该组织单位未在其中注册 Amazon Control Tower。有关更多信息,请参阅《Amazon Control Tower
用户指南》中的引用 Amazon Control Tower的外部资源。
创建 OU
-
登录 Amazon Organizations 控制台。您必须以 IAM 用户的身份登录,担任 IAM 角色;或在组织的管理账户中以根用户的身份登录(不推荐)。
-
导航到Amazon Web Services 账户页面。
控制台会显示根 OU 及其内容。首次访问根时,控制台在该顶级视图中显示所有 Amazon Web Services 账户
。如果您以前创建了 OU 并将账户移动到其中,则控制台仅显示顶级 OU 以及任何您尚未移动到 OU 中的账户。
-
(可选)如果要在现有 OU 内部创建 OU,请通过选择子 OU 的名称(而不是复选框)或在树视图中选择 OU 旁边的
来导航到该子 OU,在您看到所需内容后,请选择其名称。
-
在层次结构中选择了正确的父 OU 后,在 Actions (操作) 菜单上的 Organizational Unit (组织部门) 下,选择 Create new (新建)
-
在 Create organizational unit (创建组织部门) 对话框中,键入要创建的 OU 的名称。
-
(可选)添加一个或多个标签,方法是选择 Add tag (添加标签),然后输入一个键和可选的值。将值留空,设置为空字符串;它并非 null。您最多可以向 OU 附加 50 个标签。
-
最后,选择 Create organizational unit (创建组织部门)。
您的新 OU 显示在父级内部。现在,您可以将账户移动到此 OU 或者为其附加策略。
创建 OU
以下代码示例演示如何使用 CreateOrganizationalUnit。
- .NET
-
- 适用于 .NET 的 Amazon SDK
-
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.");
}
}
}
- 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",
"Path": "o-exampleorgid/r-examplerootid111/ou-examplerootid111-exampleouid111/"
}
}