Use DescribePolicy with an AWS SDK or CLI - AWS Organizations

Use DescribePolicy with an AWS SDK or CLI

The following code examples show how to use DescribePolicy.

CLI
AWS CLI

To get information about a policy

The following example shows how to request information about a policy:

aws organizations describe-policy --policy-id p-examplepolicyid111

The output includes a policy object that contains details about the policy:

{ "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" } } }
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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
  • For API details, see DescribePolicy in AWS SDK for Python (Boto3) API Reference.

SAP ABAP
SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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.
  • For API details, see DescribePolicy in AWS SDK for SAP ABAP API reference.

For a complete list of AWS SDK developer guides and code examples, see Using AWS Organizations with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.