Skip to content

IAM  >  Operations  >  get_role_policy

get_role_policy

Operation

get_role_policy async

get_role_policy(request: GetRolePolicyInput | GetRolePolicyInputDict, /, *, plugins: list[Plugin] | None = None) -> GetRolePolicyOutput
get_role_policy(*, plugins: list[Plugin] | None = None, **kwargs: Unpack[GetRolePolicyInputDict]) -> GetRolePolicyOutput

Retrieves the specified inline policy document that is embedded with the specified IAM role.

Note

Policies returned by this operation are URL-encoded compliant with RFC 3986. You can use a URL decoding method to convert the policy back to plain JSON text. For example, if you use Java, you can use the decode method of the java.net.URLDecoder utility class in the Java SDK. Other languages and SDKs provide similar functionality, and some SDKs do this decoding automatically.

An IAM role can also have managed policies attached to it. To retrieve a managed policy document that is attached to a role, use GetPolicy to determine the policy's default version, then use GetPolicyVersion to retrieve the policy document.

For more information about policies, see Managed policies and inline policies in the IAM User Guide.

For more information about roles, see IAM roles in the IAM User Guide.

Parameters:

Name Type Description Default
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
GetRolePolicyOutput

An instance of GetRolePolicyOutput.

Input

Pass the input fields as keyword arguments, or pass a model or dictionary as the first positional argument. Pass plugins separately as a keyword argument.

Model

GetRolePolicyInput dataclass

Bases: _SerdeShape

Dataclass for GetRolePolicyInput structure.

Attributes
policy_name class-attribute instance-attribute
policy_name: str | None = ...

The name of the policy document to get.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

role_name class-attribute instance-attribute
role_name: str | None = ...

The name of the role associated with the policy.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Dictionaries

GetRolePolicyInputDict

Bases: TypedDict

Dictionary form of GetRolePolicyInput.

Attributes
policy_name instance-attribute
policy_name: Required[str]

The name of the policy document to get.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

role_name instance-attribute
role_name: Required[str]

The name of the role associated with the policy.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Output

GetRolePolicyOutput dataclass

Bases: _SerdeShape

Contains the response to a successful GetRolePolicy request.

Attributes

policy_document instance-attribute
policy_document: str

The policy document.

IAM stores policies in JSON format. However, resources that were created using CloudFormation templates can be formatted in YAML. CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.

policy_name instance-attribute
policy_name: str

The name of the policy.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

role_name instance-attribute
role_name: str

The role the policy is associated with.