View a markdown version of this page

GetRequestAuthorizationPolicy - IAM Toolbox

GetRequestAuthorizationPolicy

Retrieves a policy that was evaluated for a specific access denied request. The operation returns the structured JSON document of the policy that was captured with the original authorization request. It doesn't retrieve the current version of the policy.

For some AWS services and policy types, the returned policy document includes all actions relevant to the service that processed the denied request, but might omit actions for other services.

Specify the authorization ID from the access denied error message and the policy URI returned by GetRequestAuthorizationDetails for the same authorization ID.

Access depends on the account and organization recorded for the principal that made the denied request. If an organization was recorded, the calling principal must belong to that organization. Otherwise, the calling principal must belong to the recorded account.

To use this operation, you must have the iam:GetRequestAuthorizationPolicy permission.

Request Syntax

GET /authorization-details/authorizationId/policy?policyUri=policyUri HTTP/1.1

URI Request Parameters

The request uses the following URI parameters.

authorizationId

The authorization ID received in the access denied error message. This ID identifies the request whose evaluated policy you want to retrieve.

Length Constraints: Minimum length of 0. Maximum length of 256.

Pattern: [0123456789abcdefghijklmnopqrstuvwxyz]+

Required: Yes

policyUri

The URI of the policy to retrieve. Use the uri value from the policies list returned by GetRequestAuthorizationDetails for the same authorization ID.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

Request Body

The request does not have a request body.

Response Syntax

HTTP/1.1 200 Content-type: application/json { "policyDocument": JSON value }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

policyDocument

The policy document evaluated for the denied request, returned as a JSON object.

For some AWS services and policy types, this document includes all actions relevant to the service that processed the denied request, but might omit actions for other services.

Type: JSON value

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

The caller does not have sufficient access to perform this action.

HTTP Status Code: 403

InternalServerException

An unexpected error occurred while processing the request. Try again.

HTTP Status Code: 500

ResourceNotFoundException

The requested policy or authorization details do not exist in this region or have expired. Verify that the authorization ID from the access denied error message is correct and the call is made in the region where the denial occurred. Ensure that the calling principal belongs to the same account or organization as the original denied request. If you specified a policy URI, verify that it is from the policies list that GetRequestAuthorizationDetails returns for the same authorization ID.

HTTP Status Code: 404

ValidationException

The request is malformed or is missing one or more required parameters. Check the request parameters and try again.

HTTP Status Code: 400

Examples

Example – Retrieve the policy for an explicitly denied iam:GetUser request

This example illustrates one usage of GetRequestAuthorizationPolicy.

Sample Request

{ "authorizationId": "z9y8x7w6v5u4t3s2r1q0", "policyUri": "arn:aws:iam::aws:policy/AWSDenyAll" }

Sample Response

{ "policyDocument": { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyAll", "Effect": "Deny", "Action": "*", "Resource": "*" } ] } }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: