与 AWS SDK或CreateOrganization一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

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

与 AWS SDK或CreateOrganization一起使用 CLI

以下代码示例演示如何使用 CreateOrganization

.NET
AWS SDK for .NET
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Creates an organization in AWS Organizations. /// </summary> public class CreateOrganization { /// <summary> /// Creates an Organizations client object and then uses it to create /// a new organization with the default user as the administrator, and /// then displays information about the new organization. /// </summary> public static async Task Main() { IAmazonOrganizations client = new AmazonOrganizationsClient(); var response = await client.CreateOrganizationAsync(new CreateOrganizationRequest { FeatureSet = "ALL", }); Organization newOrg = response.Organization; Console.WriteLine($"Organization: {newOrg.Id} Main Accoount: {newOrg.MasterAccountId}"); } }
  • 有关API详细信息,请参阅 “AWS SDK for .NET API参考 CreateOrganization” 中的。

CLI
AWS CLI

示例 1:创建新组织

Bill 想使用账户 111111111111 中的凭证创建一个组织。以下示例显示该账户成为新组织中的主账户。由于他没有指定功能集,因此,新组织默认为在根上启用所有功能并启用服务控制策略。

aws organizations create-organization

输出包括一个组织对象,其中包含有关新组织的详细信息:

{ "Organization": { "AvailablePolicyTypes": [ { "Status": "ENABLED", "Type": "SERVICE_CONTROL_POLICY" } ], "MasterAccountId": "111111111111", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "FeatureSet": "ALL", "Id": "o-exampleorgid", "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid" } }

示例 2:创建仅启用整合账单功能的新组织

以下示例创建仅支持整合账单功能的组织:

aws organizations create-organization --feature-set CONSOLIDATED_BILLING

输出包括一个组织对象,其中包含有关新组织的详细信息:

{ "Organization": { "Arn": "arn:aws:organizations::111111111111:organization/o-exampleorgid", "AvailablePolicyTypes": [], "Id": "o-exampleorgid", "MasterAccountArn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111", "MasterAccountEmail": "bill@example.com", "MasterAccountId": "111111111111", "FeatureSet": "CONSOLIDATED_BILLING" } }

有关更多信息,请参阅《AWS Organizations 用户指南》中的“创建组织”。