

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Contoh kode untuk Organizations menggunakan AWS SDKs
<a name="organizations_code_examples"></a>

Contoh kode berikut menunjukkan cara menggunakan AWS Organizations kit pengembangan AWS perangkat lunak (SDK).

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

*Skenario* adalah contoh kode yang menunjukkan kepada Anda bagaimana menyelesaikan tugas tertentu dengan memanggil beberapa fungsi dalam layanan atau dikombinasikan dengan yang lain Layanan AWS.

**Sumber daya lainnya**
+  **[Panduan Pengguna Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)** — Informasi lebih lanjut tentang Organizations.
+ **[Referensi API Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)** — Detail tentang semua tindakan Organizations yang tersedia.
+ **[AWS Pusat Pengembang](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23organizations)** - Contoh kode yang dapat Anda filter berdasarkan kategori atau pencarian teks lengkap.
+ **[AWS Contoh SDK](https://github.com/awsdocs/aws-doc-sdk-examples)** — GitHub repo dengan kode lengkap dalam bahasa pilihan. Termasuk instruksi untuk mengatur dan menjalankan kode.

**Contents**
+ [Hal-hal mendasar](organizations_code_examples_basics.md)
  + [Tindakan](organizations_code_examples_actions.md)
    + [`AttachPolicy`](organizations_example_organizations_AttachPolicy_section.md)
    + [`CreateAccount`](organizations_example_organizations_CreateAccount_section.md)
    + [`CreateOrganization`](organizations_example_organizations_CreateOrganization_section.md)
    + [`CreateOrganizationalUnit`](organizations_example_organizations_CreateOrganizationalUnit_section.md)
    + [`CreatePolicy`](organizations_example_organizations_CreatePolicy_section.md)
    + [`DeleteOrganization`](organizations_example_organizations_DeleteOrganization_section.md)
    + [`DeleteOrganizationalUnit`](organizations_example_organizations_DeleteOrganizationalUnit_section.md)
    + [`DeletePolicy`](organizations_example_organizations_DeletePolicy_section.md)
    + [`DescribePolicy`](organizations_example_organizations_DescribePolicy_section.md)
    + [`DetachPolicy`](organizations_example_organizations_DetachPolicy_section.md)
    + [`ListAccounts`](organizations_example_organizations_ListAccounts_section.md)
    + [`ListOrganizationalUnitsForParent`](organizations_example_organizations_ListOrganizationalUnitsForParent_section.md)
    + [`ListPolicies`](organizations_example_organizations_ListPolicies_section.md)
+ [Skenario](organizations_code_examples_scenarios.md)
  + [Kebijakan izin memungkinkan AWS Compute Optimizer Otomasi untuk menerapkan tindakan yang disarankan](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section.md)
  + [Kebijakan izin untuk mengaktifkan Otomasi di seluruh organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section.md)
  + [Kebijakan izin untuk mengaktifkan Otomasi untuk akun Anda](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section.md)
  + [Kebijakan izin untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section.md)
  + [Kebijakan izin untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun mandiri AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section.md)
  + [Kebijakan izin untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section.md)
  + [Kebijakan izin untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun mandiri AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section.md)
  + [Kebijakan izin untuk memberikan izin peran terkait layanan untuk Otomatisasi Pengoptimalan Komputasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section.md)

# Contoh dasar untuk Organizations menggunakan AWS SDKs
<a name="organizations_code_examples_basics"></a>

Contoh kode berikut menunjukkan cara menggunakan dasar-dasar AWS Organizations dengan AWS SDKs. 

**Contents**
+ [Tindakan](organizations_code_examples_actions.md)
  + [`AttachPolicy`](organizations_example_organizations_AttachPolicy_section.md)
  + [`CreateAccount`](organizations_example_organizations_CreateAccount_section.md)
  + [`CreateOrganization`](organizations_example_organizations_CreateOrganization_section.md)
  + [`CreateOrganizationalUnit`](organizations_example_organizations_CreateOrganizationalUnit_section.md)
  + [`CreatePolicy`](organizations_example_organizations_CreatePolicy_section.md)
  + [`DeleteOrganization`](organizations_example_organizations_DeleteOrganization_section.md)
  + [`DeleteOrganizationalUnit`](organizations_example_organizations_DeleteOrganizationalUnit_section.md)
  + [`DeletePolicy`](organizations_example_organizations_DeletePolicy_section.md)
  + [`DescribePolicy`](organizations_example_organizations_DescribePolicy_section.md)
  + [`DetachPolicy`](organizations_example_organizations_DetachPolicy_section.md)
  + [`ListAccounts`](organizations_example_organizations_ListAccounts_section.md)
  + [`ListOrganizationalUnitsForParent`](organizations_example_organizations_ListOrganizationalUnitsForParent_section.md)
  + [`ListPolicies`](organizations_example_organizations_ListPolicies_section.md)

# Tindakan untuk Organizations menggunakan AWS SDKs
<a name="organizations_code_examples_actions"></a>

Contoh kode berikut menunjukkan bagaimana melakukan tindakan Organisasi individu dengan AWS SDKs. Setiap contoh menyertakan tautan ke GitHub, di mana Anda dapat menemukan instruksi untuk mengatur dan menjalankan kode. 

Kutipan ini memanggil Organizations API dan merupakan kutipan kode dari program yang lebih besar yang harus dijalankan dalam konteks. Anda dapat melihat tindakan dalam konteks di[Skenario untuk Organizations menggunakan AWS SDKs](organizations_code_examples_scenarios.md). 

 Contoh berikut hanya mencakup tindakan yang paling umum digunakan. Untuk daftar lengkapnya, lihat [Referensi AWS Organizations API](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html). 

**Topics**
+ [`AttachPolicy`](organizations_example_organizations_AttachPolicy_section.md)
+ [`CreateAccount`](organizations_example_organizations_CreateAccount_section.md)
+ [`CreateOrganization`](organizations_example_organizations_CreateOrganization_section.md)
+ [`CreateOrganizationalUnit`](organizations_example_organizations_CreateOrganizationalUnit_section.md)
+ [`CreatePolicy`](organizations_example_organizations_CreatePolicy_section.md)
+ [`DeleteOrganization`](organizations_example_organizations_DeleteOrganization_section.md)
+ [`DeleteOrganizationalUnit`](organizations_example_organizations_DeleteOrganizationalUnit_section.md)
+ [`DeletePolicy`](organizations_example_organizations_DeletePolicy_section.md)
+ [`DescribePolicy`](organizations_example_organizations_DescribePolicy_section.md)
+ [`DetachPolicy`](organizations_example_organizations_DetachPolicy_section.md)
+ [`ListAccounts`](organizations_example_organizations_ListAccounts_section.md)
+ [`ListOrganizationalUnitsForParent`](organizations_example_organizations_ListOrganizationalUnitsForParent_section.md)
+ [`ListPolicies`](organizations_example_organizations_ListPolicies_section.md)

# Gunakan `AttachPolicy` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_AttachPolicy_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`AttachPolicy`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Shows how to attach an AWS Organizations policy to an organization,
    /// an organizational unit, or an account.
    /// </summary>
    public class AttachPolicy
    {
        /// <summary>
        /// Initializes the Organizations client object and then calls the
        /// AttachPolicyAsync method to attach the policy to the root
        /// organization.
        /// </summary>
        public static async Task Main()
        {
            IAmazonOrganizations client = new AmazonOrganizationsClient();
            var policyId = "p-00000000";
            var targetId = "r-0000";

            var request = new AttachPolicyRequest
            {
                PolicyId = policyId,
                TargetId = targetId,
            };

            var response = await client.AttachPolicyAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"Successfully attached Policy ID {policyId} to Target ID: {targetId}.");
            }
            else
            {
                Console.WriteLine("Was not successful in attaching the policy.");
            }
        }
    }
```
+  Untuk detail API, lihat [AttachPolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/AttachPolicy)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk melampirkan kebijakan ke root, OU, atau akun**  
**Contoh 1**  
Contoh berikut menunjukkan cara melampirkan kebijakan kontrol layanan (SCP) ke OU:  

```
aws organizations attach-policy
                --policy-id p-examplepolicyid111
                --target-id ou-examplerootid111-exampleouid111
```
**Contoh 2**  
Contoh berikut menunjukkan cara melampirkan kebijakan kontrol layanan langsung ke akun:  

```
aws organizations attach-policy
                --policy-id p-examplepolicyid111
                --target-id 333333333333
```
+  Untuk detail API, lihat [AttachPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/attach-policy.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def attach_policy(policy_id, target_id, orgs_client):
    """
    Attaches a policy to a target. The target is an organization root, account, or
    organizational unit.

    :param policy_id: The ID of the policy to attach.
    :param target_id: The ID of the resources to attach the policy to.
    :param orgs_client: The Boto3 Organizations client.
    """
    try:
        orgs_client.attach_policy(PolicyId=policy_id, TargetId=target_id)
        logger.info("Attached policy %s to target %s.", policy_id, target_id)
    except ClientError:
        logger.exception(
            "Couldn't attach policy %s to target %s.", policy_id, target_id
        )
        raise
```
+  Untuk detail API, lihat [AttachPolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/AttachPolicy)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        lo_org->attachpolicy(
          iv_policyid = iv_policy_id
          iv_targetid = iv_target_id ).
        MESSAGE 'Policy attached to target.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to attach the policy.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicynotfoundex.
        MESSAGE 'The specified policy does not exist.' TYPE 'E'.
      CATCH /aws1/cx_orgtargetnotfoundex.
        MESSAGE 'The specified target does not exist.' TYPE 'E'.
      CATCH /aws1/cx_orgduplicateplyatta00.
        MESSAGE 'The policy is already attached to the target.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [AttachPolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `CreateAccount` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_CreateAccount_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`CreateAccount`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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 AWS Organizations account.
    /// </summary>
    public class CreateAccount
    {
        /// <summary>
        /// Initializes an Organizations client object and uses it to create
        /// the new account with the name specified in accountName.
        /// </summary>
        public static async Task Main()
        {
            IAmazonOrganizations client = new AmazonOrganizationsClient();
            var accountName = "ExampleAccount";
            var email = "someone@example.com";

            var request = new CreateAccountRequest
            {
                AccountName = accountName,
                Email = email,
            };

            var response = await client.CreateAccountAsync(request);
            var status = response.CreateAccountStatus;

            Console.WriteLine($"The staus of {status.AccountName} is {status.State}.");
        }
    }
```
+  Untuk detail API, lihat [CreateAccount](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateAccount)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk membuat akun anggota yang secara otomatis menjadi bagian dari organisasi**  
Contoh berikut menunjukkan cara membuat akun anggota dalam suatu organisasi. Akun anggota dikonfigurasi dengan nama Akun Produksi dan alamat email susan@example.com. Organizations secara otomatis membuat peran IAM menggunakan nama default OrganizationAccountAccessRole karena parameter RoleName tidak ditentukan. Selain itu, pengaturan yang memungkinkan pengguna IAM atau peran dengan izin yang cukup untuk mengakses data penagihan akun diatur ke nilai default ALLOW karena IamUserAccessToBilling parameter tidak ditentukan. Organizations secara otomatis mengirimkan email “Selamat Datang di AWS” kepada Susan:  

```
aws organizations create-account --email susan@example.com --account-name "Production Account"
```
Outputnya mencakup objek permintaan yang menunjukkan bahwa statusnya sekarang`IN_PROGRESS`:  

```
{
        "CreateAccountStatus": {
                "State": "IN_PROGRESS",
                "Id": "car-examplecreateaccountrequestid111"
        }
}
```
Anda nantinya dapat menanyakan status permintaan saat ini dengan memberikan nilai respons Id ke describe-create-account-status perintah sebagai nilai untuk create-account-request-id parameter.  
Untuk informasi selengkapnya, lihat Membuat AWS Akun di Organisasi Anda di *Panduan Pengguna AWS Organizations*.  
+  Untuk detail API, lihat [CreateAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-account.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `CreateOrganization` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_CreateOrganization_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`CreateOrganization`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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 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}");
        }
    }
```
+  Untuk detail API, lihat [CreateOrganization](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateOrganization)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Contoh 1: Untuk membuat organisasi baru**  
Bill ingin membuat organisasi menggunakan kredensil dari akun 111111111111. Contoh berikut menunjukkan bahwa akun menjadi akun utama di organisasi baru. Karena dia tidak menentukan set fitur, organisasi baru default ke semua fitur yang diaktifkan dan kebijakan kontrol layanan diaktifkan di root.  

```
aws organizations create-organization
```
Outputnya mencakup objek organisasi dengan rincian tentang organisasi baru:  

```
{
        "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"
        }
}
```
**Contoh 2: Untuk membuat organisasi baru dengan hanya fitur penagihan terkonsolidasi yang diaktifkan**  
Contoh berikut membuat organisasi yang hanya mendukung fitur penagihan konsolidasi:  

```
aws organizations create-organization --feature-set CONSOLIDATED_BILLING
```
Outputnya mencakup objek organisasi dengan rincian tentang organisasi baru:  

```
{
        "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"
        }
}
```
Untuk informasi selengkapnya, lihat Membuat Organisasi di *Panduan Pengguna AWS Organizations*.  
+  Untuk detail API, lihat [CreateOrganization](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-organization.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `CreateOrganizationalUnit` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_CreateOrganizationalUnit_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`CreateOrganizationalUnit`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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.");
            }
        }
    }
```
+  Untuk detail API, lihat [CreateOrganizationalUnit](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateOrganizationalUnit)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk membuat OU di root atau induk OU**  
Contoh berikut menunjukkan cara membuat OU yang bernama AccountingOu:  

```
aws organizations create-organizational-unit --parent-id r-examplerootid111 --name AccountingOU
```
Outputnya mencakup objek OrganizationalUnit dengan detail tentang OU baru:  

```
{
        "OrganizationalUnit": {
                "Id": "ou-examplerootid111-exampleouid111",
                "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111",
                "Name": "AccountingOU"
        }
}
```
+  Untuk detail API, lihat [CreateOrganizationalUnit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-organizational-unit.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `CreatePolicy` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_CreatePolicy_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`CreatePolicy`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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 AWS Organizations Policy.
    /// </summary>
    public class CreatePolicy
    {
        /// <summary>
        /// Initializes the AWS Organizations client object, uses it to
        /// create a new Organizations Policy, and then displays information
        /// about the newly created Policy.
        /// </summary>
        public static async Task Main()
        {
            IAmazonOrganizations client = new AmazonOrganizationsClient();
            var policyContent = "{" +
                "   \"Version\": \"2012-10-17\"," +
                "	\"Statement\" : [{" +
                    "	\"Action\" : [\"s3:*\"]," +
                    "	\"Effect\" : \"Allow\"," +
                    "	\"Resource\" : \"*\"" +
                "}]" +
            "}";

            try
            {
                var response = await client.CreatePolicyAsync(new CreatePolicyRequest
                {
                    Content = policyContent,
                    Description = "Enables admins of attached accounts to delegate all Amazon S3 permissions",
                    Name = "AllowAllS3Actions",
                    Type = "SERVICE_CONTROL_POLICY",
                });

                Policy policy = response.Policy;
                Console.WriteLine($"{policy.PolicySummary.Name} has the following content: {policy.Content}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
```
+  Untuk detail API, lihat [CreatePolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreatePolicy)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Contoh 1: Untuk membuat kebijakan dengan file sumber teks untuk kebijakan JSON**  
Contoh berikut menunjukkan cara membuat kebijakan kontrol layanan (SCP) bernama`AllowAllS3Actions`. Isi kebijakan diambil dari file di komputer lokal yang disebut`policy.json`.  

```
aws organizations create-policy --content file://policy.json --name AllowAllS3Actions, --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"
```
Outputnya mencakup objek kebijakan dengan detail tentang kebijakan baru:  

```
{
        "Policy": {
                "Content": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}",
                "PolicySummary": {
                        "Arn": "arn:aws:organizations::o-exampleorgid:policy/service_control_policy/p-examplepolicyid111",
                        "Description": "Allows delegation of all S3 actions",
                        "Name": "AllowAllS3Actions",
                        "Type":"SERVICE_CONTROL_POLICY"
                }
        }
}
```
**Contoh 2: Untuk membuat kebijakan dengan kebijakan JSON sebagai parameter**  
Contoh berikut menunjukkan cara membuat SCP yang sama, kali ini dengan menyematkan konten kebijakan sebagai string JSON dalam parameter. String harus lolos dengan garis miring terbalik sebelum tanda kutip ganda untuk memastikan bahwa mereka diperlakukan sebagai literal dalam parameter, yang dengan sendirinya dikelilingi oleh tanda kutip ganda:  

```
aws organizations create-policy --content "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}" --name AllowAllS3Actions --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"
```
Untuk informasi selengkapnya tentang membuat dan menggunakan kebijakan di organisasi Anda, lihat Mengelola Kebijakan *AWS Organisasi di Panduan Pengguna Organizations*.  
+  Untuk detail API, lihat [CreatePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-policy.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def create_policy(name, description, content, policy_type, orgs_client):
    """
    Creates a policy.

    :param name: The name of the policy.
    :param description: The description of the policy.
    :param content: The policy content as a dict. This is converted to JSON before
                    it is sent to AWS. The specific format depends on the policy type.
    :param policy_type: The type of the policy.
    :param orgs_client: The Boto3 Organizations client.
    :return: The newly created policy.
    """
    try:
        response = orgs_client.create_policy(
            Name=name,
            Description=description,
            Content=json.dumps(content),
            Type=policy_type,
        )
        policy = response["Policy"]
        logger.info("Created policy %s.", name)
    except ClientError:
        logger.exception("Couldn't create policy %s.", name)
        raise
    else:
        return policy
```
+  Untuk detail API, lihat [CreatePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/CreatePolicy)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        oo_result = lo_org->createpolicy(       " oo_result is returned for testing purposes. "
          iv_name        = iv_policy_name
          iv_description = iv_policy_description
          iv_content     = iv_policy_content
          iv_type        = iv_policy_type ).
        MESSAGE 'Policy created.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to create a policy.' TYPE 'E'.
      CATCH /aws1/cx_orgduplicatepolicyex.
        MESSAGE 'A policy with this name already exists.' TYPE 'E'.
      CATCH /aws1/cx_orgmalformedplydocex.
        MESSAGE 'The policy content is malformed.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [CreatePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `DeleteOrganization` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_DeleteOrganization_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DeleteOrganization`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Shows how to delete an existing organization using the AWS
    /// Organizations Service.
    /// </summary>
    public class DeleteOrganization
    {
        /// <summary>
        /// Initializes the Organizations client and then calls
        /// DeleteOrganizationAsync to delete the organization.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var response = await client.DeleteOrganizationAsync(new DeleteOrganizationRequest());

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine("Successfully deleted organization.");
            }
            else
            {
                Console.WriteLine("Could not delete organization.");
            }
        }
    }
```
+  Untuk detail API, lihat [DeleteOrganization](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeleteOrganization)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk menghapus organisasi**  
Contoh berikut menunjukkan cara menghapus organisasi. Untuk melakukan operasi ini, Anda harus menjadi admin akun master di organisasi. Contoh ini mengasumsikan bahwa Anda sebelumnya menghapus semua akun anggota OUs, dan kebijakan dari organisasi:  

```
aws organizations delete-organization
```
+  Untuk detail API, lihat [DeleteOrganization](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-organization.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `DeleteOrganizationalUnit` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_DeleteOrganizationalUnit_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DeleteOrganizationalUnit`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// 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}.");
            }
        }
    }
```
+  Untuk detail API, lihat [DeleteOrganizationalUnit](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeleteOrganizationalUnit)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk menghapus OU**  
Contoh berikut menunjukkan cara menghapus OU. Contoh mengasumsikan bahwa Anda sebelumnya menghapus semua akun dan lainnya OUs dari OU:  

```
aws organizations delete-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111
```
+  Untuk detail API, lihat [DeleteOrganizationalUnit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-organizational-unit.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `DeletePolicy` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_DeletePolicy_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DeletePolicy`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Deletes an existing AWS Organizations policy.
    /// </summary>
    public class DeletePolicy
    {
        /// <summary>
        /// Initializes the Organizations client object and then uses it to
        /// delete the policy with the specified policyId.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var policyId = "p-00000000";

            var request = new DeletePolicyRequest
            {
                PolicyId = policyId,
            };

            var response = await client.DeletePolicyAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"Successfully deleted Policy: {policyId}.");
            }
            else
            {
                Console.WriteLine($"Could not delete Policy: {policyId}.");
            }
        }
    }
```
+  Untuk detail API, lihat [DeletePolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeletePolicy)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk menghapus kebijakan**  
Contoh berikut menunjukkan cara menghapus kebijakan dari organisasi. Contoh ini mengasumsikan bahwa Anda sebelumnya melepaskan kebijakan dari semua entitas:  

```
aws organizations delete-policy --policy-id p-examplepolicyid111
```
+  Untuk detail API, lihat [DeletePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-policy.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def delete_policy(policy_id, orgs_client):
    """
    Deletes a policy.

    :param policy_id: The ID of the policy to delete.
    :param orgs_client: The Boto3 Organizations client.
    """
    try:
        orgs_client.delete_policy(PolicyId=policy_id)
        logger.info("Deleted policy %s.", policy_id)
    except ClientError:
        logger.exception("Couldn't delete policy %s.", policy_id)
        raise
```
+  Untuk detail API, lihat [DeletePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DeletePolicy)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        lo_org->deletepolicy(
          iv_policyid = iv_policy_id ).
        MESSAGE 'Policy deleted.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to delete the policy.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicynotfoundex.
        MESSAGE 'The specified policy does not exist.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicyinuseex.
        MESSAGE 'The policy is still attached to one or more targets.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [DeletePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `DescribePolicy` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_DescribePolicy_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribePolicy`.

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

**AWS CLI**  
**Untuk mendapatkan informasi tentang kebijakan**  
Contoh berikut menunjukkan cara meminta informasi tentang kebijakan:  

```
aws organizations describe-policy --policy-id p-examplepolicyid111
```
Outputnya mencakup objek kebijakan yang berisi detail tentang kebijakan:  

```
{
        "Policy": {
                "Content": "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": \"*\",\n      \"Resource\": \"*\"\n    }\n  ]\n}",
                "PolicySummary": {
                        "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111",
                        "Type": "SERVICE_CONTROL_POLICY",
                        "Id": "p-examplepolicyid111",
                        "AwsManaged": false,
                        "Name": "AllowAllS3Actions",
                        "Description": "Enables admins to delegate S3 permissions"
                }
        }
}
```
+  Untuk detail API, lihat [DescribePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/describe-policy.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def describe_policy(policy_id, orgs_client):
    """
    Describes a policy.

    :param policy_id: The ID of the policy to describe.
    :param orgs_client: The Boto3 Organizations client.
    :return: The description of the policy.
    """
    try:
        response = orgs_client.describe_policy(PolicyId=policy_id)
        policy = response["Policy"]
        logger.info("Got policy %s.", policy_id)
    except ClientError:
        logger.exception("Couldn't get policy %s.", policy_id)
        raise
    else:
        return policy
```
+  Untuk detail API, lihat [DescribePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DescribePolicy)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        oo_result = lo_org->describepolicy(     " oo_result is returned for testing purposes. "
          iv_policyid = iv_policy_id ).
        DATA(lo_policy) = oo_result->get_policy( ).
        MESSAGE 'Retrieved policy details.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to describe the policy.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicynotfoundex.
        MESSAGE 'The specified policy does not exist.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [DescribePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `DetachPolicy` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_DetachPolicy_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DetachPolicy`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Shows how to detach a policy from an AWS Organizations organization,
    /// organizational unit, or account.
    /// </summary>
    public class DetachPolicy
    {
        /// <summary>
        /// Initializes the Organizations client object and uses it to call
        /// DetachPolicyAsync to detach the policy.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var policyId = "p-00000000";
            var targetId = "r-0000";

            var request = new DetachPolicyRequest
            {
                PolicyId = policyId,
                TargetId = targetId,
            };

            var response = await client.DetachPolicyAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"Successfully detached policy with Policy Id: {policyId}.");
            }
            else
            {
                Console.WriteLine("Could not detach the policy.");
            }
        }
    }
```
+  Untuk detail API, lihat [DetachPolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DetachPolicy)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk melepaskan kebijakan dari root, OU, atau akun**  
Contoh berikut menunjukkan cara melepaskan kebijakan dari OU:  

```
aws organizations  detach-policy  --target-id ou-examplerootid111-exampleouid111 --policy-id p-examplepolicyid111
```
+  Untuk detail API, lihat [DetachPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/detach-policy.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def detach_policy(policy_id, target_id, orgs_client):
    """
    Detaches a policy from a target.

    :param policy_id: The ID of the policy to detach.
    :param target_id: The ID of the resource where the policy is currently attached.
    :param orgs_client: The Boto3 Organizations client.
    """
    try:
        orgs_client.detach_policy(PolicyId=policy_id, TargetId=target_id)
        logger.info("Detached policy %s from target %s.", policy_id, target_id)
    except ClientError:
        logger.exception(
            "Couldn't detach policy %s from target %s.", policy_id, target_id
        )
        raise
```
+  Untuk detail API, lihat [DetachPolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DetachPolicy)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        lo_org->detachpolicy(
          iv_policyid = iv_policy_id
          iv_targetid = iv_target_id ).
        MESSAGE 'Policy detached from target.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to detach the policy.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicynotfoundex.
        MESSAGE 'The specified policy does not exist.' TYPE 'E'.
      CATCH /aws1/cx_orgtargetnotfoundex.
        MESSAGE 'The specified target does not exist.' TYPE 'E'.
      CATCH /aws1/cx_orgpolicynotattex.
        MESSAGE 'The policy is not attached to the target.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [DetachPolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Gunakan `ListAccounts` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_ListAccounts_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`ListAccounts`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Uses the AWS Organizations service to list the accounts associated
    /// with the default account.
    /// </summary>
    public class ListAccounts
    {
        /// <summary>
        /// Creates the Organizations client and then calls its
        /// ListAccountsAsync method.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var request = new ListAccountsRequest
            {
                MaxResults = 5,
            };

            var response = new ListAccountsResponse();
            try
            {
                do
                {
                    response = await client.ListAccountsAsync(request);
                    response.Accounts.ForEach(a => DisplayAccounts(a));
                    if (response.NextToken is not null)
                    {
                        request.NextToken = response.NextToken;
                    }
                }
                while (response.NextToken is not null);
            }
            catch (AWSOrganizationsNotInUseException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        /// <summary>
        /// Displays information about an Organizations account.
        /// </summary>
        /// <param name="account">An Organizations account for which to display
        /// information on the console.</param>
        private static void DisplayAccounts(Account account)
        {
            string accountInfo = $"{account.Id} {account.Name}\t{account.Status}";

            Console.WriteLine(accountInfo);
        }
    }
```
+  Untuk detail API, lihat [ListAccounts](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListAccounts)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk mengambil daftar semua akun dalam suatu organisasi**  
Contoh berikut menunjukkan cara meminta daftar akun di organisasi:  

```
aws organizations list-accounts
```
Outputnya mencakup daftar objek ringkasan akun.  

```
{
        "Accounts": [
                {
                        "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/111111111111",
                        "JoinedMethod": "INVITED",
                        "JoinedTimestamp": 1481830215.45,
                        "Id": "111111111111",
                        "Name": "Master Account",
                        "Email": "bill@example.com",
                        "Status": "ACTIVE"
                },
                {
                        "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/222222222222",
                        "JoinedMethod": "INVITED",
                        "JoinedTimestamp": 1481835741.044,
                        "Id": "222222222222",
                        "Name": "Production Account",
                        "Email": "alice@example.com",
                        "Status": "ACTIVE"
                },
                {
                        "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/333333333333",
                        "JoinedMethod": "INVITED",
                        "JoinedTimestamp": 1481835795.536,
                        "Id": "333333333333",
                        "Name": "Development Account",
                        "Email": "juan@example.com",
                        "Status": "ACTIVE"
                },
                {
                        "Arn": "arn:aws:organizations::111111111111:account/o-exampleorgid/444444444444",
                        "JoinedMethod": "INVITED",
                        "JoinedTimestamp": 1481835812.143,
                        "Id": "444444444444",
                        "Name": "Test Account",
                        "Email": "anika@example.com",
                        "Status": "ACTIVE"
                }
        ]
}
```
+  Untuk detail API, lihat [ListAccounts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-accounts.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `ListOrganizationalUnitsForParent` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_ListOrganizationalUnitsForParent_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`ListOrganizationalUnitsForParent`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Lists the AWS Organizations organizational units that belong to an
    /// organization.
    /// </summary>
    public class ListOrganizationalUnitsForParent
    {
        /// <summary>
        /// Initializes the Organizations client object and then uses it to
        /// call the ListOrganizationalUnitsForParentAsync method to retrieve
        /// the list of organizational units.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var parentId = "r-0000";

            var request = new ListOrganizationalUnitsForParentRequest
            {
                ParentId = parentId,
                MaxResults = 5,
            };

            var response = new ListOrganizationalUnitsForParentResponse();
            try
            {
                do
                {
                    response = await client.ListOrganizationalUnitsForParentAsync(request);
                    response.OrganizationalUnits.ForEach(u => DisplayOrganizationalUnit(u));
                    if (response.NextToken is not null)
                    {
                        request.NextToken = response.NextToken;
                    }
                }
                while (response.NextToken is not null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        /// <summary>
        /// Displays information about an Organizations organizational unit.
        /// </summary>
        /// <param name="unit">The OrganizationalUnit for which to display
        /// information.</param>
        public static void DisplayOrganizationalUnit(OrganizationalUnit unit)
        {
            string accountInfo = $"{unit.Id} {unit.Name}\t{unit.Arn}";

            Console.WriteLine(accountInfo);
        }
    }
```
+  Untuk detail API, lihat [ListOrganizationalUnitsForParent](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListOrganizationalUnitsForParent)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk mengambil daftar OU atau root induk OUs **  
Contoh berikut menunjukkan kepada Anda cara mendapatkan daftar OUs di root tertentu:  

```
aws organizations list-organizational-units-for-parent --parent-id r-examplerootid111
```
Output menunjukkan bahwa root yang ditentukan berisi dua OUs dan menunjukkan rincian masing-masing:  

```
{
        "OrganizationalUnits": [
                {
                        "Name": "AccountingDepartment",
                        "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid111"
                },
                {
                        "Name": "ProductionDepartment",
                        "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid222"
                }
        ]
}
```
+  Untuk detail API, lihat [ListOrganizationalUnitsForParent](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-organizational-units-for-parent.html)di *Referensi AWS CLI Perintah*. 

------

# Gunakan `ListPolicies` dengan AWS SDK atau CLI
<a name="organizations_example_organizations_ListPolicies_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`ListPolicies`.

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

**SDK untuk .NET**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](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>
    /// Shows how to list the AWS Organizations policies associated with an
    /// organization.
    /// </summary>
    public class ListPolicies
    {
        /// <summary>
        /// Initializes an Organizations client object, and then calls its
        /// ListPoliciesAsync method.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            // The value for the Filter parameter is required and must must be
            // one of the following:
            //     AISERVICES_OPT_OUT_POLICY
            //     BACKUP_POLICY
            //     SERVICE_CONTROL_POLICY
            //     TAG_POLICY
            var request = new ListPoliciesRequest
            {
                Filter = "SERVICE_CONTROL_POLICY",
                MaxResults = 5,
            };

            var response = new ListPoliciesResponse();
            try
            {
                do
                {
                    response = await client.ListPoliciesAsync(request);
                    response.Policies.ForEach(p => DisplayPolicies(p));
                    if (response.NextToken is not null)
                    {
                        request.NextToken = response.NextToken;
                    }
                }
                while (response.NextToken is not null);
            }
            catch (AWSOrganizationsNotInUseException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        /// <summary>
        /// Displays information about the Organizations policies associated
        /// with an organization.
        /// </summary>
        /// <param name="policy">An Organizations policy summary to display
        /// information on the console.</param>
        private static void DisplayPolicies(PolicySummary policy)
        {
            string policyInfo = $"{policy.Id} {policy.Name}\t{policy.Description}";

            Console.WriteLine(policyInfo);
        }
    }
```
+  Untuk detail API, lihat [ListPolicies](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListPolicies)di *Referensi AWS SDK untuk .NET API*. 

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

**AWS CLI**  
**Untuk mengambil daftar semua kebijakan dalam organisasi dari jenis tertentu**  
Contoh berikut menunjukkan cara untuk mendapatkan daftar SCPs, seperti yang ditentukan oleh parameter filter:  

```
aws organizations list-policies --filter SERVICE_CONTROL_POLICY
```
Outputnya mencakup daftar kebijakan dengan informasi ringkasan:  

```
{
        "Policies": [
                {
                        "Type": "SERVICE_CONTROL_POLICY",
                        "Name": "AllowAllS3Actions",
                        "AwsManaged": false,
                        "Id": "p-examplepolicyid111",
                        "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid111",
                        "Description": "Enables account admins to delegate permissions for any S3 actions to users and roles in their accounts."
                },
                {
                        "Type": "SERVICE_CONTROL_POLICY",
                        "Name": "AllowAllEC2Actions",
                        "AwsManaged": false,
                        "Id": "p-examplepolicyid222",
                        "Arn": "arn:aws:organizations::111111111111:policy/service_control_policy/p-examplepolicyid222",
                        "Description": "Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts."
                },
                {
                        "AwsManaged": true,
                        "Description": "Allows access to every operation",
                        "Type": "SERVICE_CONTROL_POLICY",
                        "Id": "p-FullAWSAccess",
                        "Arn": "arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess",
                        "Name": "FullAWSAccess"
                }
        ]
}
```
+  Untuk detail API, lihat [ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-policies.html)di *Referensi AWS CLI Perintah*. 

------
#### [ Python ]

**SDK untuk Python (Boto3)**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples). 

```
def list_policies(policy_filter, orgs_client):
    """
    Lists the policies for the account, limited to the specified filter.

    :param policy_filter: The kind of policies to return.
    :param orgs_client: The Boto3 Organizations client.
    :return: The list of policies found.
    """
    try:
        response = orgs_client.list_policies(Filter=policy_filter)
        policies = response["Policies"]
        logger.info("Found %s %s policies.", len(policies), policy_filter)
    except ClientError:
        logger.exception("Couldn't get %s policies.", policy_filter)
        raise
    else:
        return policies
```
+  Untuk detail API, lihat [ListPolicies](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/ListPolicies)di *AWS SDK for Python (Boto3) Referensi* API. 

------
#### [ SAP ABAP ]

**SDK for SAP ABAP**  
 Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di [Repositori Contoh Kode AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples). 

```
    TRY.
        oo_result = lo_org->listpolicies(       " oo_result is returned for testing purposes. "
          iv_filter = iv_filter ).
        DATA(lt_policies) = oo_result->get_policies( ).
        MESSAGE 'Retrieved list of policies.' TYPE 'I'.
      CATCH /aws1/cx_orgaccessdeniedex.
        MESSAGE 'You do not have permission to list policies.' TYPE 'E'.
      CATCH /aws1/cx_orgawsorgsnotinuseex.
        MESSAGE 'Your account is not a member of an organization.' TYPE 'E'.
    ENDTRY.
```
+  Untuk detail API, lihat [ListPolicies](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)di *AWS SDK untuk referensi SAP ABAP* API. 

------

# Skenario untuk Organizations menggunakan AWS SDKs
<a name="organizations_code_examples_scenarios"></a>

Contoh kode berikut menunjukkan cara menerapkan skenario umum di Organizations with AWS SDKs. Skenario ini menunjukkan kepada Anda bagaimana menyelesaikan tugas tertentu dengan memanggil beberapa fungsi dalam Organizations atau dikombinasikan dengan yang lain Layanan AWS. Setiap skenario menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode. 

Skenario menargetkan tingkat pengalaman menengah untuk membantu Anda memahami tindakan layanan dalam konteks.

**Topics**
+ [Kebijakan izin memungkinkan AWS Compute Optimizer Otomasi untuk menerapkan tindakan yang disarankan](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section.md)
+ [Kebijakan izin untuk mengaktifkan Otomasi di seluruh organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section.md)
+ [Kebijakan izin untuk mengaktifkan Otomasi untuk akun Anda](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section.md)
+ [Kebijakan izin untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section.md)
+ [Kebijakan izin untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun mandiri AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section.md)
+ [Kebijakan izin untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section.md)
+ [Kebijakan izin untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun mandiri AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section.md)
+ [Kebijakan izin untuk memberikan izin peran terkait layanan untuk Otomatisasi Pengoptimalan Komputasi](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section.md)

# Memungkinkan fitur AWS Compute Optimizer Otomasi menerapkan tindakan yang disarankan
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memungkinkan fitur AWS Compute Optimizer Otomatisasi menerapkan tindakan yang disarankan

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "aco-automation.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

# Kebijakan untuk mengaktifkan Otomasi di seluruh organisasi Anda
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memungkinkan Otomasi di seluruh organisasi Anda

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iam:CreateServiceLinkedRole",
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation",
            "Condition": {"StringLike": {"iam:AWSServiceName": "aco-automation.amazonaws.com"}}
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:PutRolePolicy", 
                "iam:AttachRolePolicy"
            ],
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation"
        },
        {
            "Effect": "Allow",
            "Action": "aco-automation:UpdateEnrollmentConfiguration",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "aco-automation:AssociateAccounts",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "aco-automation:DisassociateAccounts",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "aco-automation:ListAccounts",
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk mengaktifkan Otomasi untuk akun Anda
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section"></a>

Contoh kode berikut menunjukkan cara mengaktifkan Kebijakan berbasis izin ini untuk akun Anda

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iam:CreateServiceLinkedRole",
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation",
            "Condition": {"StringLike": {"iam:AWSServiceName": "aco-automation.amazonaws.com"}}
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:PutRolePolicy", 
                "iam:AttachRolePolicy"
            ],
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation"
        },
        {
            "Effect": "Allow",
            "Action": "aco-automation:UpdateEnrollmentConfiguration",
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memberikan akses penuh ke Otomatisasi Pengoptimal Komputasi untuk akun manajemen organisasi

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
               "aco-automation:*",
               "ec2:DescribeVolumes",
               "organizations:ListAccounts",
               "organizations:DescribeOrganization",
               "organizations:DescribeAccount",
               "organizations:EnableAWSServiceAccess",
               "organizations:ListDelegatedAdministrators",
               "organizations:RegisterDelegatedAdministrator",
               "organizations:DeregisterDelegatedAdministrator"
            ],
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk memberikan akses penuh ke Otomatisasi Compute Optimizer untuk akun mandiri AWS
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memberikan akses penuh ke Otomatisasi Pengoptimal Komputasi untuk akun mandiri AWS 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
               "aco-automation:*",
            "ec2:DescribeVolumes"
            ],
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun manajemen organisasi
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memberikan akses hanya-baca ke Otomatisasi Pengoptimal Komputasi untuk akun manajemen organisasi

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
               "aco-automation:GetEnrollmentConfiguration",
               "aco-automation:GetAutomationEvent",
               "aco-automation:GetAutomationRule",
               "aco-automation:ListAccounts",
               "aco-automation:ListAutomationEvents",
               "aco-automation:ListAutomationEventSteps",
               "aco-automation:ListAutomationEventSummaries",
               "aco-automation:ListAutomationRules",
               "aco-automation:ListAutomationRulePreview",
               "aco-automation:ListAutomationRulePreviewSummaries",
               "aco-automation:ListRecommendedActions",
               "aco-automation:ListRecommendedActionSummaries",
               "aco-automation:ListTagsForResource",
               "ec2:DescribeVolumes"
            ],
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk memberikan akses hanya-baca ke Otomatisasi Compute Optimizer untuk akun mandiri AWS
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memberikan akses hanya-baca ke Otomatisasi Pengoptimal Komputasi untuk akun mandiri AWS 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
               "aco-automation:GetEnrollmentConfiguration",
               "aco-automation:GetAutomationEvent",
               "aco-automation:GetAutomationRule",
               "aco-automation:ListAutomationEvents",
               "aco-automation:ListAutomationEventSteps",
               "aco-automation:ListAutomationEventSummaries",
               "aco-automation:ListAutomationRules",
               "aco-automation:ListAutomationRulePreview",
               "aco-automation:ListAutomationRulePreviewSummaries",
               "aco-automation:ListRecommendedActions",
               "aco-automation:ListRecommendedActionSummaries",
               "aco-automation:ListTagsForResource",
               "ec2:DescribeVolumes"
            ],
            "Resource": "*"
        }
    ]
}
```

------

# Kebijakan untuk memberikan izin peran terkait layanan untuk Otomatisasi Pengoptimalan Komputasi
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section"></a>

Contoh kode berikut menunjukkan cara Kebijakan berbasis izin ini memberikan izin peran terkait layanan untuk Otomatisasi Pengoptimalan Komputasi

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	                    
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iam:CreateServiceLinkedRole",
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation",
            "Condition": {"StringLike": {"iam:AWSServiceName": "aco-automation.amazonaws.com"}}
        },
        {
            "Effect": "Allow",
            "Action": "iam:PutRolePolicy",
            "Resource": "arn:aws:iam::*:role/aws-service-role/aco-automation.amazonaws.com/AWSServiceRoleForComputeOptimizerAutomation"
        }
    ]
}
```

------