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
When calling List* operations, always check the
NextTokenresponse parameter value, even if you receive an empty result set. These operations can occasionally return an empty set of results even when more results are available. Continue making requests untilNextTokenreturns null. A nullNextTokenvalue indicates that you have retrieved all available results.You can only call this operation from the management account or a member account that is a delegated administrator.
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'|'SECURITYHUB_POLICY'|'INSPECTOR_POLICY'|'UPGRADE_ROLLOUT_POLICY'|'BEDROCK_POLICY'|'S3_POLICY', 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
NextTokenresponse in a previous request. ANextTokenresponse indicates that more output is available. Set this parameter to the value of the previous call’sNextTokenresponse to indicate where the output should continue from.MaxResults (integer) – The maximum number of items to return in the response. If more results exist than the specified
MaxResultsvalue, a token is included in the response so that you can retrieve the remaining 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'|'SECURITYHUB_POLICY'|'INSPECTOR_POLICY'|'UPGRADE_ROLLOUT_POLICY'|'BEDROCK_POLICY'|'S3_POLICY', '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
NextTokenrequest parameter in a subsequent call to the operation to get the next part of the output. You should repeat this until theNextTokenresponse element comes back asnull.
Exceptions
Organizations.Client.exceptions.AWSOrganizationsNotInUseExceptionOrganizations.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': { '...': '...', }, }