Verwendung ListPolicies mit einem AWS SDK oder CLI - AWS Organizations

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.

Verwendung ListPolicies mit einem AWS SDK oder CLI

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

.NET
SDK for .NET
Anmerkung

Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel- 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 ListPoliciesin der AWS SDK for .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 ListPoliciesunter AWS CLI Befehlsreferenz.

Python
SDK für Python (Boto3)
Anmerkung

Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel- 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 ListPoliciesin AWS SDK for Python (Boto3) API Reference.

SAP ABAP
SDK für SAP ABAP
Anmerkung

Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel- 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 ListPoliciesin der API-Referenz zum AWS SDK für SAP ABAP.

Eine vollständige Liste der AWS SDK-Entwicklerhandbücher und Codebeispiele finden Sie unterVerwendung AWS Organizations mit einem SDK AWS. Dieses Thema enthält auch Informationen zu den ersten Schritten und Details zu früheren SDK-Versionen.