Use DescribePolicy with an Amazon SDK or CLI - Amazon Organizations
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use DescribePolicy with an Amazon SDK or CLI

The following code examples show how to use DescribePolicy.

CLI
Amazon 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" } } }
  • For API details, see DescribePolicy in Amazon CLI Command Reference.

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 Amazon 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 Amazon SDK for Python (Boto3) API Reference.

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