Organizations / Client / list_policies

list_policies#

Organizations.Client.list_policies(**kwargs)#

Retrieves the list of all policies in an organization of a specified type.

Note

Always check the NextToken response parameter for a null value when calling a List* operation. These operations can occasionally return an empty set of results even when there are more results available. The NextToken response parameter value is null only when there are no more results to display.

This operation can be called only from the organization’s management account or by a member account that is a delegated administrator for an Amazon Web Services service.

See also: AWS API Documentation

Request Syntax

response = client.list_policies(
    Filter='SERVICE_CONTROL_POLICY'|'RESOURCE_CONTROL_POLICY'|'TAG_POLICY'|'BACKUP_POLICY'|'AISERVICES_OPT_OUT_POLICY'|'CHATBOT_POLICY'|'DECLARATIVE_POLICY_EC2',
    NextToken='string',
    MaxResults=123
)
Parameters:
  • Filter (string) –

    [REQUIRED]

    Specifies the type of policy that you want to include in the response. You must specify one of the following values:

  • NextToken (string) – The parameter for receiving additional results if you receive a NextToken response in a previous request. A NextToken response indicates that more output is available. Set this parameter to the value of the previous call’s NextToken response to indicate where the output should continue from.

  • MaxResults (integer) – The total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (is not null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that Organizations might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

Return type:

dict

Returns:

Response Syntax

{
    'Policies': [
        {
            'Id': 'string',
            'Arn': 'string',
            'Name': 'string',
            'Description': 'string',
            'Type': 'SERVICE_CONTROL_POLICY'|'RESOURCE_CONTROL_POLICY'|'TAG_POLICY'|'BACKUP_POLICY'|'AISERVICES_OPT_OUT_POLICY'|'CHATBOT_POLICY'|'DECLARATIVE_POLICY_EC2',
            'AwsManaged': True|False
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • Policies (list) –

      A list of policies that match the filter criteria in the request. The output list doesn’t include the policy contents. To see the content for a policy, see DescribePolicy.

      • (dict) –

        Contains information about a policy, but does not include the content. To see the content of a policy, see DescribePolicy.

        • Id (string) –

          The unique identifier (ID) of the policy.

          The regex pattern for a policy ID string requires “p-” followed by from 8 to 128 lowercase or uppercase letters, digits, or the underscore character (_).

        • Arn (string) –

          The Amazon Resource Name (ARN) of the policy.

          For more information about ARNs in Organizations, see ARN Formats Supported by Organizations in the Amazon Web Services Service Authorization Reference.

        • Name (string) –

          The friendly name of the policy.

          The regex pattern that is used to validate this parameter is a string of any of the characters in the ASCII character range.

        • Description (string) –

          The description of the policy.

        • Type (string) –

          The type of policy.

        • AwsManaged (boolean) –

          A boolean value that indicates whether the specified policy is an Amazon Web Services managed policy. If true, then you can attach the policy to roots, OUs, or accounts, but you cannot edit it.

    • NextToken (string) –

      If present, indicates that more output is available than is included in the current response. Use this value in the NextToken request parameter in a subsequent call to the operation to get the next part of the output. You should repeat this until the NextToken response element comes back as null.

Exceptions

  • Organizations.Client.exceptions.AccessDeniedException

  • Organizations.Client.exceptions.AWSOrganizationsNotInUseException

  • Organizations.Client.exceptions.InvalidInputException

  • Organizations.Client.exceptions.ServiceException

  • Organizations.Client.exceptions.TooManyRequestsException

  • Organizations.Client.exceptions.UnsupportedAPIEndpointException

Examples

The following example shows how to get a list of service control policies (SCPs):/n/n

response = client.list_policies(
    Filter='SERVICE_CONTROL_POLICY',
)

print(response)

Expected Output:

{
    'Policies': [
        {
            'Arn': 'arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111',
            'AwsManaged': False,
            'Description': 'Enables account admins to delegate permissions for any S3 actions to users and roles in their accounts.',
            'Id': 'p-examplepolicyid111',
            'Name': 'AllowAllS3Actions',
            'Type': 'SERVICE_CONTROL_POLICY',
        },
        {
            'Arn': 'arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid222',
            'AwsManaged': False,
            'Description': 'Enables account admins to delegate permissions for any EC2 actions to users and roles in their accounts.',
            'Id': 'p-examplepolicyid222',
            'Name': 'AllowAllEC2Actions',
            'Type': 'SERVICE_CONTROL_POLICY',
        },
        {
            'Arn': 'arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess',
            'AwsManaged': True,
            'Description': 'Allows access to every operation',
            'Id': 'p-FullAWSAccess',
            'Name': 'FullAWSAccess',
            'Type': 'SERVICE_CONTROL_POLICY',
        },
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}