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

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

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

DeleteOrganizationalUnit 搭配 a AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 DeleteOrganizationalUnit

.NET
AWS SDK for .NET
注意

還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Shows how to delete an existing AWS Organizations organizational unit. /// </summary> public class DeleteOrganizationalUnit { /// <summary> /// Initializes the Organizations client object and calls /// DeleteOrganizationalUnitAsync to delete the organizational unit /// with the selected ID. /// </summary> public static async Task Main() { // Create the client object using the default account. IAmazonOrganizations client = new AmazonOrganizationsClient(); var orgUnitId = "ou-0000-00000000"; var request = new DeleteOrganizationalUnitRequest { OrganizationalUnitId = orgUnitId, }; var response = await client.DeleteOrganizationalUnitAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"Successfully deleted the organizational unit with ID: {orgUnitId}."); } else { Console.WriteLine($"Could not delete the organizational unit with ID: {orgUnitId}."); } } }
CLI
AWS CLI

若要刪除 OU

下列範例顯示如何刪除 OU。此範例假設您先前已從 OU 移除所有帳戶和其他 OUs:

aws organizations delete-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111