CreateOrganization 搭配 AWS SDK或 使用 CLI - AWS SDK 程式碼範例

文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK GitHub

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

CreateOrganization 搭配 AWS SDK或 使用 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詳細資訊,請參閱 參考 CreateOrganization中的 。 AWS SDK for .NET API

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 使用者指南 中的建立組織