

Weitere AWS SDK-Beispiele sind im GitHub Repo [AWS Doc SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples) verfügbar.

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Codebeispiele für Organizations, die AWS SDKs
<a name="organizations_code_examples"></a>

Die folgenden Codebeispiele zeigen Ihnen, wie Sie es AWS Organizations mit einem AWS Software Development Kit (SDK) verwenden.

*Aktionen* sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Während Aktionen Ihnen zeigen, wie Sie einzelne Service-Funktionen aufrufen, können Sie Aktionen im Kontext der zugehörigen Szenarien anzeigen.

*Szenarien* sind Codebeispiele, die Ihnen zeigen, wie Sie bestimmte Aufgaben ausführen, indem Sie mehrere Funktionen innerhalb eines Service aufrufen oder mit anderen AWS-Services kombinieren.

**Weitere -Quellen**
+  **[Benutzerhandbuch zu Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)** – Weitere Informationen zu Organizations.
+ **[API-Referenz für Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)** – Details zu allen verfügbaren Organizations-Aktionen.
+ **[AWS Developer Center](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23organizations)** — Codebeispiele, die Sie nach Kategorie oder Volltextsuche filtern können.
+ **[AWS SDK-Beispiele](https://github.com/awsdocs/aws-doc-sdk-examples)** — GitHub Repo mit vollständigem Code in bevorzugten Sprachen. Enthält Anleitungen zum Einrichten und Ausführen des Codes.

**Contents**
+ [Grundlagen](organizations_code_examples_basics.md)
  + [Aktionen](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)
+ [Szenarien](organizations_code_examples_scenarios.md)
  + [Die Berechtigungsrichtlinie ermöglicht es der AWS Compute Optimizer Automatisierung, empfohlene Aktionen anzuwenden](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section.md)
  + [Genehmigungsrichtlinie zur Aktivierung der Automatisierung in Ihrer gesamten Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section.md)
  + [Genehmigungsrichtlinie zur Aktivierung der Automatisierung für Ihr Konto](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section.md)
  + [Berechtigungsrichtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section.md)
  + [Berechtigungsrichtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für eigenständige Konten AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section.md)
  + [Berechtigungsrichtlinie zur Gewährung von schreibgeschütztem Zugriff auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section.md)
  + [Berechtigungsrichtlinie zur Gewährung von schreibgeschütztem Zugriff auf Compute Optimizer Automation für eigenständige Konten AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section.md)
  + [Berechtigungsrichtlinie zur Erteilung von dienstbezogenen Rollenberechtigungen für Compute Optimization Automation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section.md)

# Grundlegende Beispiele für Organizations, die AWS SDKs
<a name="organizations_code_examples_basics"></a>

Die folgenden Codebeispiele zeigen, wie die Grundlagen von AWS Organizations with verwendet AWS SDKs werden. 

**Contents**
+ [Aktionen](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)

# Aktionen für Organizations, die AWS SDKs
<a name="organizations_code_examples_actions"></a>

Die folgenden Codebeispiele zeigen, wie einzelne Organisationsaktionen mit ausgeführt AWS SDKs werden. Jedes Beispiel enthält einen Link zu GitHub, wo Sie Anweisungen zum Einrichten und Ausführen des Codes finden. 

Diese Auszüge rufen die Organizations-API auf und sind Codeauszüge aus größeren Programmen, die im Kontext ausgeführt werden müssen. Sie können Aktionen im Kontext unter [Szenarien für Organizations, die AWS SDKs](organizations_code_examples_scenarios.md) anzeigen. 

 Die folgenden Beispiele enthalten nur die am häufigsten verwendeten Aktionen. Eine vollständige Liste finden Sie in der [AWS Organizations -API-Referenz](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)

# Verwendung `AttachPolicy` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_AttachPolicy_section"></a>

Die folgenden Code-Beispiele zeigen, wie `AttachPolicy` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [AttachPolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/AttachPolicy)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So hängen Sie eine Richtlinie an ein Stammverzeichnis, eine Organisationsrichtlinie oder ein Konto an**  
**Beispiel 1**  
Das folgende Beispiel zeigt, wie Sie eine Service-Kontrollrichtlinie (SCP) an eine Organisationseinheit anfügen:  

```
aws organizations attach-policy
                --policy-id p-examplepolicyid111
                --target-id ou-examplerootid111-exampleouid111
```
**Beispiel 2**  
Das folgende Beispiel zeigt, wie Sie eine Service-Kontrollrichtlinie direkt an ein Konto anfügen:  

```
aws organizations attach-policy
                --policy-id p-examplepolicyid111
                --target-id 333333333333
```
+  Einzelheiten zur API finden Sie [AttachPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/attach-policy.html)in der *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [AttachPolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/AttachPolicy)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [AttachPolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Verwendung `CreateAccount` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_CreateAccount_section"></a>

Die folgenden Code-Beispiele zeigen, wie `CreateAccount` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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}.");
        }
    }
```
+  Einzelheiten zur API finden Sie [CreateAccount](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateAccount)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So erstellen Sie ein Mitgliedskonto, das automatisch Teil Ihrer Organisation ist**  
Das folgende Beispiel zeigt, wie ein Mitgliedskonto in einer Organisation erstellt wird. Das Mitgliedskonto ist mit dem Namen Production Account und der E-Mail-Adresse susan@example.com konfiguriert. Organizations erstellt automatisch eine IAM-Rolle mit dem Standardnamen von, OrganizationAccountAccessRole da der RoleName-Parameter nicht angegeben ist. Außerdem ist die Einstellung, die IAM-Benutzern oder -Rollen mit ausreichenden Berechtigungen den Zugriff auf Kontoabrechnungsdaten ermöglicht, auf den Standardwert ALLOW gesetzt, da der IamUserAccessToBilling Parameter nicht angegeben ist. Organizations sendet Susan automatisch eine „Willkommen bei AWS“ -E-Mail:  

```
aws organizations create-account --email susan@example.com --account-name "Production Account"
```
Die Ausgabe umfasst ein Anforderungsobjekt, aus dem hervorgeht, dass der Status jetzt `IN_PROGRESS` lautet:  

```
{
        "CreateAccountStatus": {
                "State": "IN_PROGRESS",
                "Id": "car-examplecreateaccountrequestid111"
        }
}
```
Sie können später den aktuellen Status der Anfrage abfragen, indem Sie den Antwortwert ID für den describe-create-account-status Befehl als Wert für den create-account-request-id Parameter angeben.  
Weitere Informationen finden Sie unter Erstellen eines AWS Kontos in Ihrer Organisation im *Benutzerhandbuch für AWS Organizations*.  
+  Einzelheiten zur API finden Sie [CreateAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-account.html)unter *AWS CLI Befehlsreferenz*. 

------

# Verwendung `CreateOrganization` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_CreateOrganization_section"></a>

Die folgenden Code-Beispiele zeigen, wie `CreateOrganization` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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}");
        }
    }
```
+  Einzelheiten zur API finden Sie [CreateOrganization](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateOrganization)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**Beispiel 1: So erstellen Sie eine neue Organisation**  
Bill möchte eine Organisation mit den Anmeldeinformationen des Kontos 111111111111 erstellen. Das folgende Beispiel zeigt, dass das Konto zum Hauptkonto in der neuen Organisation wird. Da er keinen Funktionsumfang angibt, sind in der neuen Organisation standardmäßig alle Funktionen aktiviert, und die Richtlinien zur Servicekontrollrichtlinien sind im Stammverzeichnis aktiviert.  

```
aws organizations create-organization
```
Die Ausgabe umfasst ein Organisationsobjekt mit Details zur neuen Organisation:  

```
{
        "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"
        }
}
```
**Beispiel 2: So erstellen Sie eine neue Organisation, für die nur konsolidierte Rechnungsstellungsfunktionen aktiviert sind**  
Im folgenden Beispiel wird eine Organisation erstellt, die nur konsolidierte Rechnungsstellungsfunktionen unterstützt:  

```
aws organizations create-organization --feature-set CONSOLIDATED_BILLING
```
Die Ausgabe umfasst ein Organisationsobjekt mit Details zur neuen Organisation:  

```
{
        "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"
        }
}
```
Weitere Informationen finden Sie unter Erstellen einer Organisation im *Benutzerhandbuch für AWS Organizations*.  
+  Einzelheiten zur API finden Sie [CreateOrganization](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-organization.html)in der *AWS CLI Befehlsreferenz*. 

------

# Verwendung `CreateOrganizationalUnit` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_CreateOrganizationalUnit_section"></a>

Die folgenden Code-Beispiele zeigen, wie `CreateOrganizationalUnit` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [CreateOrganizationalUnit](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreateOrganizationalUnit)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So erstellen Sie eine Organisationseinheit in einer Stamm- oder übergeordneten Organisationseinheit**  
Das folgende Beispiel zeigt, wie eine Organisationseinheit mit dem Namen AccountingOU erstellt wird:  

```
aws organizations create-organizational-unit --parent-id r-examplerootid111 --name AccountingOU
```
Die Ausgabe umfasst ein organizationalUnit-Objekt mit Details zur neuen Organisationseinheit:  

```
{
        "OrganizationalUnit": {
                "Id": "ou-examplerootid111-exampleouid111",
                "Arn": "arn:aws:organizations::111111111111:ou/o-exampleorgid/ou-examplerootid111-exampleouid111",
                "Name": "AccountingOU"
        }
}
```
+  Einzelheiten zur API finden Sie [CreateOrganizationalUnit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-organizational-unit.html)in der *AWS CLI Befehlsreferenz*. 

------

# Verwendung `CreatePolicy` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_CreatePolicy_section"></a>

Die folgenden Code-Beispiele zeigen, wie `CreatePolicy` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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);
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [CreatePolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/CreatePolicy)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**Beispiel 1: So erstellen Sie eine Richtlinie mit einer Textquelldatei für die JSON-Richtlinie**  
Das folgende Beispiel zeigt, wie Sie eine Service-Kontrollrichtlinie (SCP) namens `AllowAllS3Actions` erstellen: Der Richtlinieninhalt stammt aus einer Datei auf dem lokalen Computer namens `policy.json`.  

```
aws organizations create-policy --content file://policy.json --name AllowAllS3Actions, --type SERVICE_CONTROL_POLICY --description "Allows delegation of all S3 actions"
```
Die Ausgabe umfasst ein Richtlinienobjekt mit Details zur neuen Richtlinie:  

```
{
        "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"
                }
        }
}
```
**Beispiel 2: So erstellen Sie eine Richtlinie mit einer JSON-Richtlinie als Parameter**  
Das folgende Beispiel zeigt, wie Sie dasselbe SCP erstellen, diesmal indem Sie den Richtlinieninhalt als JSON-Zeichenfolge in den Parameter einbetten. Die Zeichenfolge muss mit Backslashes vor den doppelten Anführungszeichen maskiert werden, um sicherzustellen, dass sie im Parameter, der selbst von doppelten Anführungszeichen umgeben ist, als Literale behandelt werden:  

```
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"
```
Weitere Informationen zum Erstellen und Verwenden von Richtlinien in Ihrer Organisation finden Sie unter „Verwalten von Organisationsrichtlinien“ im *Benutzerhandbuch für AWS Organizations*.  
+  Einzelheiten zur API finden Sie [CreatePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/create-policy.html)in der *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [CreatePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/CreatePolicy)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [CreatePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Verwendung `DeleteOrganization` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_DeleteOrganization_section"></a>

Die folgenden Code-Beispiele zeigen, wie `DeleteOrganization` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [DeleteOrganization](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeleteOrganization)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**Um eine Organisation zu löschen**  
Im folgenden Beispiel wird gezeigt, wie eine Organisation gelöscht wird. Um diesen Vorgang ausführen zu können, müssen Sie Administrator des Hauptkontos in der Organisation sein. Das Beispiel geht davon aus, dass Sie zuvor alle Mitgliedskonten OUs und Richtlinien aus der Organisation entfernt haben:  

```
aws organizations delete-organization
```
+  Einzelheiten zur API finden Sie [DeleteOrganization](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-organization.html)unter *AWS CLI Befehlsreferenz*. 

------

# Verwendung `DeleteOrganizationalUnit` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_DeleteOrganizationalUnit_section"></a>

Die folgenden Code-Beispiele zeigen, wie `DeleteOrganizationalUnit` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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}.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [DeleteOrganizationalUnit](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeleteOrganizationalUnit)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**Um eine Organisationseinheit zu löschen**  
Im folgenden Beispiel wird gezeigt, wie eine Organisationseinheit gelöscht wird. Das Beispiel geht davon aus, dass Sie zuvor alle Konten und andere Konten OUs aus der Organisationseinheit entfernt haben:  

```
aws organizations delete-organizational-unit --organizational-unit-id ou-examplerootid111-exampleouid111
```
+  Einzelheiten zur API finden Sie [DeleteOrganizationalUnit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-organizational-unit.html)in der *AWS CLI Befehlsreferenz*. 

------

# Verwendung `DeletePolicy` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_DeletePolicy_section"></a>

Die folgenden Code-Beispiele zeigen, wie `DeletePolicy` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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}.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [DeletePolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DeletePolicy)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So löschen Sie eine Richtlinie**  
Das folgende Codebeispiel zeigt, wie Sie eine Richtlinie aus einer Organisation löschen. Im Beispiel wird davon ausgegangen, dass Sie die Richtlinie zuvor von allen Entitäten getrennt haben:  

```
aws organizations delete-policy --policy-id p-examplepolicyid111
```
+  Einzelheiten zur API finden Sie [DeletePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/delete-policy.html)in der *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [DeletePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DeletePolicy)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [DeletePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Verwendung `DescribePolicy` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_DescribePolicy_section"></a>

Die folgenden Code-Beispiele zeigen, wie `DescribePolicy` verwendet wird.

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

**AWS CLI**  
**So rufen Sie Informationen zu einer Richtlinie ab**  
Das folgende Beispiel zeigt, wie Sie Informationen zu einer Richtlinie anfordern:  

```
aws organizations describe-policy --policy-id p-examplepolicyid111
```
Die Ausgabe umfasst ein Richtlinienobjekt, das Details zur Richtlinie enthält:  

```
{
        "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"
                }
        }
}
```
+  Einzelheiten zur API finden Sie [DescribePolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/describe-policy.html)in der *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [DescribePolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DescribePolicy)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [DescribePolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Verwendung `DetachPolicy` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_DetachPolicy_section"></a>

Die folgenden Code-Beispiele zeigen, wie `DetachPolicy` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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.");
            }
        }
    }
```
+  Einzelheiten zur API finden Sie [DetachPolicy](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/DetachPolicy)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So trennen Sie eine Richtlinie von einem Root, einer Organisationseinheit oder einem Konto**  
Das folgende Codebeispiel zeigt, wie Sie eine Richtlinie von einer Organisationseinheit trennen.  

```
aws organizations  detach-policy  --target-id ou-examplerootid111-exampleouid111 --policy-id p-examplepolicyid111
```
+  Einzelheiten zur API finden Sie [DetachPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/detach-policy.html)in der *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [DetachPolicy](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/DetachPolicy)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [DetachPolicy](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Verwendung `ListAccounts` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_ListAccounts_section"></a>

Die folgenden Code-Beispiele zeigen, wie `ListAccounts` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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);
        }
    }
```
+  Einzelheiten zur API finden Sie [ListAccounts](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListAccounts)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So rufen Sie eine Liste aller Konten in einer Organisation ab**  
Das folgende Beispiel zeigt, wie Sie eine Liste der Konten in einer Organisation anfordern:  

```
aws organizations list-accounts
```
Die Ausgabe enthält eine Liste von Kontozusammenfassungsobjekten.  

```
{
        "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"
                }
        ]
}
```
+  Einzelheiten zur API finden Sie [ListAccounts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-accounts.html)in der *AWS CLI Befehlsreferenz*. 

------

# Verwendung `ListOrganizationalUnitsForParent` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_ListOrganizationalUnitsForParent_section"></a>

Die folgenden Code-Beispiele zeigen, wie `ListOrganizationalUnitsForParent` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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);
        }
    }
```
+  Einzelheiten zur API finden Sie [ListOrganizationalUnitsForParent](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListOrganizationalUnitsForParent)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**Um eine Liste der OUs in einer übergeordneten Organisationseinheit oder einem Stammverzeichnis abzurufen**  
Das folgende Beispiel zeigt Ihnen, wie Sie eine Liste von OUs in einem angegebenen Stammverzeichnis abrufen:  

```
aws organizations list-organizational-units-for-parent --parent-id r-examplerootid111
```
Die Ausgabe zeigt, dass der angegebene Stamm zwei enthält, OUs und es werden Details zu jedem Stamm angezeigt:  

```
{
        "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"
                }
        ]
}
```
+  Einzelheiten zur API finden Sie [ListOrganizationalUnitsForParent](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-organizational-units-for-parent.html)in der *AWS CLI Befehlsreferenz*. 

------

# Verwendung `ListPolicies` mit einem AWS SDK oder CLI
<a name="organizations_example_organizations_ListPolicies_section"></a>

Die folgenden Code-Beispiele zeigen, wie `ListPolicies` verwendet wird.

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

**SDK für .NET**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/Organizations#code-examples) einrichten und ausführen. 

```
    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);
        }
    }
```
+  Einzelheiten zur API finden Sie [ListPolicies](https://docs.aws.amazon.com/goto/DotNetSDKV3/organizations-2016-11-28/ListPolicies)in der *AWS SDK für .NET API-Referenz*. 

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

**AWS CLI**  
**So rufen Sie eine Liste aller Richtlinien in einer Organisation eines bestimmten Typs ab**  
Das folgende Beispiel zeigt Ihnen, wie Sie eine Liste von SCPs, wie im Filterparameter angegeben, abrufen können:  

```
aws organizations list-policies --filter SERVICE_CONTROL_POLICY
```
Die Ausgabe umfasst eine Liste von Richtlinien mit zusammenfassenden Informationen:  

```
{
        "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"
                }
        ]
}
```
+  Einzelheiten zur API finden Sie [ListPolicies](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/organizations/list-policies.html)unter *AWS CLI Befehlsreferenz*. 

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

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/organizations#code-examples) einrichten und ausführen. 

```
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
```
+  Einzelheiten zur API finden Sie [ListPolicies](https://docs.aws.amazon.com/goto/boto3/organizations-2016-11-28/ListPolicies)in *AWS SDK for Python (Boto3) API* Reference. 

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

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/org#code-examples) einrichten und ausführen. 

```
    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.
```
+  Einzelheiten zur API finden Sie [ListPolicies](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------

# Szenarien für Organizations, die AWS SDKs
<a name="organizations_code_examples_scenarios"></a>

Die folgenden Codebeispiele zeigen Ihnen, wie Sie gängige Szenarien in Organizations mit implementieren AWS SDKs. Diese Szenarien zeigen Ihnen, wie Sie bestimmte Aufgaben erledigen können, indem Sie mehrere Funktionen innerhalb von Organizations aufrufen oder mit anderen kombinieren AWS-Services. Jedes Szenario enthält einen Link zum vollständigen Quell-Code, wo Sie Anleitungen zum Einrichten und Ausführen des Codes finden. 

Szenarien zielen auf eine mittlere Erfahrungsebene ab, um Ihnen zu helfen, Service-Aktionen im Kontext zu verstehen.

**Topics**
+ [Die Berechtigungsrichtlinie ermöglicht es der AWS Compute Optimizer Automatisierung, empfohlene Aktionen anzuwenden](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section.md)
+ [Genehmigungsrichtlinie zur Aktivierung der Automatisierung in Ihrer gesamten Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section.md)
+ [Genehmigungsrichtlinie zur Aktivierung der Automatisierung für Ihr Konto](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section.md)
+ [Berechtigungsrichtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section.md)
+ [Berechtigungsrichtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für eigenständige Konten AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section.md)
+ [Berechtigungsrichtlinie zur Gewährung von schreibgeschütztem Zugriff auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section.md)
+ [Berechtigungsrichtlinie zur Gewährung von schreibgeschütztem Zugriff auf Compute Optimizer Automation für eigenständige Konten AWS](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section.md)
+ [Berechtigungsrichtlinie zur Erteilung von dienstbezogenen Rollenberechtigungen für Compute Optimization Automation](organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section.md)

# Ermöglicht der AWS Compute Optimizer Automatisierungsfunktion, empfohlene Aktionen anzuwenden
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.managed-policies.xml.10_section"></a>

Das folgende Codebeispiel zeigt, wie das geht: Diese berechtigungsbasierte Richtlinie ermöglicht es der AWS Compute Optimizer Automatisierungsfunktion, empfohlene Aktionen anzuwenden

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

****  

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

------

# Richtlinie zur Aktivierung der Automatisierung in Ihrer gesamten Organisation
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.2_section"></a>

Das folgende Codebeispiel zeigt, wie Sie mit dieser berechtigungsbasierten Richtlinie die Automatisierung in Ihrer gesamten Organisation aktivieren

------
#### [ 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": "*"
        }
    ]
}
```

------

# Richtlinie zur Aktivierung der Automatisierung für Ihr Konto
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.1_section"></a>

Das folgende Codebeispiel zeigt, wie Sie mit dieser berechtigungsbasierten Richtlinie die Automatisierung für Ihr Konto aktivieren

------
#### [ 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": "*"
        }
    ]
}
```

------

# Richtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.5_section"></a>

Das folgende Codebeispiel zeigt, wie das geht: Diese berechtigungsbasierte Richtlinie gewährt einem Verwaltungskonto einer Organisation vollen Zugriff auf Compute Optimizer Automation.

------
#### [ 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": "*"
        }
    ]
}
```

------

# Richtlinie zur Gewährung des vollen Zugriffs auf Compute Optimizer Automation für eigenständige Konten AWS
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.3_section"></a>

Das folgende Codebeispiel zeigt, wie Sie mit dieser berechtigungsbasierten Richtlinie eigenständigen Konten vollen Zugriff auf Compute Optimizer Automation gewähren AWS 

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

****  

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

------

# Richtlinie zur Gewährung von schreibgeschütztem Zugriff auf Compute Optimizer Automation für ein Verwaltungskonto einer Organisation
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.6_section"></a>

Das folgende Codebeispiel zeigt, wie: Diese berechtigungsbasierte Richtlinie gewährt einem Verwaltungskonto einer Organisation schreibgeschützten Zugriff auf Compute Optimizer Automation.

------
#### [ 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": "*"
        }
    ]
}
```

------

# Richtlinie zur Gewährung von Lesezugriff auf Compute Optimizer Automation für eigenständige Konten AWS
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.automation.xml.4_section"></a>

Das folgende Codebeispiel zeigt, wie das geht: Diese berechtigungsbasierte Richtlinie gewährt eigenständigen Konten schreibgeschützten Zugriff auf Compute Optimizer Automation. 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": "*"
        }
    ]
}
```

------

# Richtlinie zur Gewährung von dienstbezogenen Rollenberechtigungen für Compute Optimization Automation
<a name="organizations_example_iam-policies.AWSMettleDocs.latest.userguide.slr-automation.xml.1_section"></a>

Das folgende Codebeispiel zeigt, wie diese berechtigungsbasierte Richtlinie dienstbezogene Rollenberechtigungen für Compute Optimization Automation gewährt

------
#### [ 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"
        }
    ]
}
```

------