AWS Identity and Access Management

2015/10/22 - AWS Identity and Access Management - 2 updated api methods

SimulateCustomPolicy (updated) Link ¶
Changes (request, response)
Request
{'CallerArn': 'string', 'ResourceOwner': 'string', 'ResourcePolicy': 'string'}
Response
{'EvaluationResults': {'EvalDecisionDetails': {'string': 'allowed | '
                                                         'explicitDeny | '
                                                         'implicitDeny'},
                       'MatchedStatements': {'SourcePolicyType': {'resource'}}}}

Simulate how a set of IAM policies and optionally a resource-based policy works with a list of API actions and AWS resources to determine the policies' effective permissions. The policies are provided as strings.

The simulation does not perform the API actions; it only checks the authorization to determine if the simulated policies allow or deny the actions.

If you want to simulate existing policies attached to an IAM user, group, or role, use SimulatePrincipalPolicy instead.

Context keys are variables maintained by AWS and its services that provide details about the context of an API query request. You can use the Condition element of an IAM policy to evaluate context keys. To get the list of context keys that the policies require for correct simulation, use GetContextKeysForCustomPolicy.

If the output is long, you can use MaxItems and Marker parameters to paginate the results.

Request Syntax

client.simulate_custom_policy(
    PolicyInputList=[
        'string',
    ],
    ActionNames=[
        'string',
    ],
    ResourceArns=[
        'string',
    ],
    ResourcePolicy='string',
    ResourceOwner='string',
    CallerArn='string',
    ContextEntries=[
        {
            'ContextKeyName': 'string',
            'ContextKeyValues': [
                'string',
            ],
            'ContextKeyType': 'string'|'stringList'|'numeric'|'numericList'|'boolean'|'booleanList'|'ip'|'ipList'|'binary'|'binaryList'|'date'|'dateList'
        },
    ],
    MaxItems=123,
    Marker='string'
)
type PolicyInputList:

list

param PolicyInputList:

[REQUIRED]

A list of policy documents to include in the simulation. Each document is specified as a string containing the complete, valid JSON text of an IAM policy. Do not include any resource-based policies in this parameter. Any resource-based policy must be submitted with the ResourcePolicy parameter. The policies cannot be "scope-down" policies, such as you could include in a call to GetFederationToken or one of the AssumeRole APIs to restrict what a user can do while using the temporary credentials.

  • (string) --

type ActionNames:

list

param ActionNames:

[REQUIRED]

A list of names of API actions to evaluate in the simulation. Each action is evaluated against each resource. Each action must include the service identifier, such as iam:CreateUser.

  • (string) --

type ResourceArns:

list

param ResourceArns:

A list of ARNs of AWS resources to include in the simulation. If this parameter is not provided then the value defaults to * (all resources). Each API in the ActionNames parameter is evaluated for each resource in this list. The simulation determines the access result (allowed or denied) of each combination and reports it in the response.

The simulation does not automatically retrieve policies for the specified resources. If you want to include a resource policy in the simulation, then you must include the policy as a string in the ResourcePolicy parameter.

If you include a ResourcePolicy, then it must be applicable to all of the resources included in the simulation or you receive an invalid input error.

  • (string) --

type ResourcePolicy:

string

param ResourcePolicy:

A resource-based policy to include in the simulation provided as a string. Each resource in the simulation is treated as if it had this policy attached. You can include only one resource-based policy in a simulation.

type ResourceOwner:

string

param ResourceOwner:

An AWS account ID that specifies the owner of any simulated resource that does not identify its owner in the resource ARN, such as an S3 bucket or object. If ResourceOwner is specified, it is also used as the account owner of any ResourcePolicy included in the simulation. If the ResourceOwner parameter is not specified, then the owner of the resources and the resource policy defaults to the account of the identity provided in CallerArn. This parameter is required only if you specify a resource-based policy and account that owns the resource is different from the account that owns the simulated calling user CallerArn.

type CallerArn:

string

param CallerArn:

The ARN of the user that you want to use as the simulated caller of the APIs. CallerArn is required if you include a ResourcePolicy so that the policy's Principal element has a value to use in evaluating the policy.

You can specify only the ARN of an IAM user. You cannot specify the ARN of an assumed role, federated user, or a service principal.

type ContextEntries:

list

param ContextEntries:

A list of context keys and corresponding values for the simulation to use. Whenever a context key is evaluated by a Condition element in one of the simulated IAM permission policies, the corresponding value is supplied.

  • (dict) --

    Contains information about a condition context key. It includes the name of the key and specifies the value (or values, if the context key supports multiple values) to use in the simulation. This information is used when evaluating the Condition elements of the input policies.

    This data type is used as an input parameter to SimulatePolicy.

    • ContextKeyName (string) --

      The full name of a condition context key, including the service prefix. For example, aws:SourceIp or s3:VersionId.

    • ContextKeyValues (list) --

      The value (or values, if the condition context key supports multiple values) to provide to the simulation for use when the key is referenced by a Condition element in an input policy.

      • (string) --

    • ContextKeyType (string) --

      The data type of the value (or values) specified in the ContextKeyValues parameter.

type MaxItems:

integer

param MaxItems:

Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the IsTruncated response element is true.

This parameter is optional. If you do not include it, it defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the IsTruncated response element returns true and Marker contains a value to include in the subsequent call that tells the service where to continue from.

type Marker:

string

param Marker:

Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the Marker element in the response that you received to indicate where the next call should start.

rtype:

dict

returns:

Response Syntax

{
    'EvaluationResults': [
        {
            'EvalActionName': 'string',
            'EvalResourceName': 'string',
            'EvalDecision': 'allowed'|'explicitDeny'|'implicitDeny',
            'MatchedStatements': [
                {
                    'SourcePolicyId': 'string',
                    'SourcePolicyType': 'user'|'group'|'role'|'aws-managed'|'user-managed'|'resource'|'none',
                    'StartPosition': {
                        'Line': 123,
                        'Column': 123
                    },
                    'EndPosition': {
                        'Line': 123,
                        'Column': 123
                    }
                },
            ],
            'MissingContextValues': [
                'string',
            ],
            'EvalDecisionDetails': {
                'string': 'allowed'|'explicitDeny'|'implicitDeny'
            }
        },
    ],
    'IsTruncated': True|False,
    'Marker': 'string'
}

Response Structure

  • (dict) --

    Contains the response to a successful SimulatePrincipalPolicy or SimulateCustomPolicy request.

    • EvaluationResults (list) --

      The results of the simulation.

      • (dict) --

        Contains the results of a simulation.

        This data type is used by the return parameter of SimulatePolicy.

        • EvalActionName (string) --

          The name of the API action tested on the indicated resource.

        • EvalResourceName (string) --

          The ARN of the resource that the indicated API action was tested on.

        • EvalDecision (string) --

          The result of the simulation.

        • MatchedStatements (list) --

          A list of the statements in the input policies that determine the result for this scenario. Remember that even if multiple statements allow the action on the resource, if only one statement denies that action, then the explicit deny overrides any allow, and the deny statement is the only entry included in the result.

          • (dict) --

            Contains a reference to a Statement element in a policy document that determines the result of the simulation.

            This data type is used by the MatchedStatements member of the EvaluationResult type.

            • SourcePolicyId (string) --

              The identifier of the policy that was provided as an input.

            • SourcePolicyType (string) --

              The type of the policy.

            • StartPosition (dict) --

              The row and column of the beginning of the Statement in an IAM policy.

              • Line (integer) --

                The line containing the specified position in the document.

              • Column (integer) --

                The column in the line containing the specified position in the document.

            • EndPosition (dict) --

              The row and column of the end of a Statement in an IAM policy.

              • Line (integer) --

                The line containing the specified position in the document.

              • Column (integer) --

                The column in the line containing the specified position in the document.

        • MissingContextValues (list) --

          A list of context keys that are required by the included input policies but that were not provided by one of the input parameters. To discover the context keys used by a set of policies, you can call GetContextKeysForCustomPolicy or GetContextKeysForPrincipalPolicy.

          If the response includes any keys in this list, then the reported results might be untrustworthy because the simulation could not completely evaluate all of the conditions specified in the policies that would occur in a real world request.

          • (string) --

        • EvalDecisionDetails (dict) --

          Additional details about the results of the evaluation decision. When there are both IAM policies and resource policies, this parameter explains how each set of policies contributes to the final evaluation decision. When simulating cross-account access to a resource, both the resource-based policy and the caller's IAM policy must grant access. See How IAM Roles Differ from Resource-based Policies

          • (string) --

            • (string) --

    • IsTruncated (boolean) --

      A flag that indicates whether there are more items to return. If your results were truncated, you can make a subsequent pagination request using the Marker request parameter to retrieve more items. Note that IAM might return fewer than the MaxItems number of results even when there are more results available. We recommend that you check IsTruncated after every call to ensure that you receive all of your results.

    • Marker (string) --

      When IsTruncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent pagination request.

SimulatePrincipalPolicy (updated) Link ¶
Changes (request, response)
Request
{'CallerArn': 'string', 'ResourceOwner': 'string', 'ResourcePolicy': 'string'}
Response
{'EvaluationResults': {'EvalDecisionDetails': {'string': 'allowed | '
                                                         'explicitDeny | '
                                                         'implicitDeny'},
                       'MatchedStatements': {'SourcePolicyType': {'resource'}}}}

Simulate how a set of IAM policies attached to an IAM entity works with a list of API actions and AWS resources to determine the policies' effective permissions. The entity can be an IAM user, group, or role. If you specify a user, then the simulation also includes all of the policies that are attached to groups that the user belongs to .

You can optionally include a list of one or more additional policies specified as strings to include in the simulation. If you want to simulate only policies specified as strings, use SimulateCustomPolicy instead.

You can also optionally include one resource-based policy to be evaluated with each of the resources included in the simulation.

The simulation does not perform the API actions, it only checks the authorization to determine if the simulated policies allow or deny the actions.

Note: This API discloses information about the permissions granted to other users. If you do not want users to see other user's permissions, then consider allowing them to use SimulateCustomPolicy instead.

Context keys are variables maintained by AWS and its services that provide details about the context of an API query request. You can use the Condition element of an IAM policy to evaluate context keys. To get the list of context keys that the policies require for correct simulation, use GetContextKeysForPrincipalPolicy.

If the output is long, you can use the MaxItems and Marker parameters to paginate the results.

Request Syntax

client.simulate_principal_policy(
    PolicySourceArn='string',
    PolicyInputList=[
        'string',
    ],
    ActionNames=[
        'string',
    ],
    ResourceArns=[
        'string',
    ],
    ResourcePolicy='string',
    ResourceOwner='string',
    CallerArn='string',
    ContextEntries=[
        {
            'ContextKeyName': 'string',
            'ContextKeyValues': [
                'string',
            ],
            'ContextKeyType': 'string'|'stringList'|'numeric'|'numericList'|'boolean'|'booleanList'|'ip'|'ipList'|'binary'|'binaryList'|'date'|'dateList'
        },
    ],
    MaxItems=123,
    Marker='string'
)
type PolicySourceArn:

string

param PolicySourceArn:

[REQUIRED]

The Amazon Resource Name (ARN) of a user, group, or role whose policies you want to include in the simulation. If you specify a user, group, or role, the simulation includes all policies that are associated with that entity. If you specify a user, the simulation also includes all policies that are attached to any groups the user belongs to.

type PolicyInputList:

list

param PolicyInputList:

An optional list of additional policy documents to include in the simulation. Each document is specified as a string containing the complete, valid JSON text of an IAM policy.

  • (string) --

type ActionNames:

list

param ActionNames:

[REQUIRED]

A list of names of API actions to evaluate in the simulation. Each action is evaluated for each resource. Each action must include the service identifier, such as iam:CreateUser.

  • (string) --

type ResourceArns:

list

param ResourceArns:

A list of ARNs of AWS resources to include in the simulation. If this parameter is not provided then the value defaults to * (all resources). Each API in the ActionNames parameter is evaluated for each resource in this list. The simulation determines the access result (allowed or denied) of each combination and reports it in the response.

The simulation does not automatically retrieve policies for the specified resources. If you want to include a resource policy in the simulation, then you must include the policy as a string in the ResourcePolicy parameter.

  • (string) --

type ResourcePolicy:

string

param ResourcePolicy:

A resource-based policy to include in the simulation provided as a string. Each resource in the simulation is treated as if it had this policy attached. You can include only one resource-based policy in a simulation.

type ResourceOwner:

string

param ResourceOwner:

An AWS account ID that specifies the owner of any simulated resource that does not identify its owner in the resource ARN, such as an S3 bucket or object. If ResourceOwner is specified, it is also used as the account owner of any ResourcePolicy included in the simulation. If the ResourceOwner parameter is not specified, then the owner of the resources and the resource policy defaults to the account of the identity provided in CallerArn. This parameter is required only if you specify a resource-based policy and account that owns the resource is different from the account that owns the simulated calling user CallerArn.

type CallerArn:

string

param CallerArn:

The ARN of the user that you want to specify as the simulated caller of the APIs. If you do not specify a CallerArn, it defaults to the ARN of the user that you specify in PolicySourceArn, if you specified a user. If you include both a PolicySourceArn (for example, arn:aws:iam::123456789012:user/David) and a CallerArn (for example, arn:aws:iam::123456789012:user/Bob), the result is that you simulate calling the APIs as Bob, as if Bob had David's policies.

You can specify only the ARN of an IAM user. You cannot specify the ARN of an assumed role, federated user, or a service principal.

CallerArn is required if you include a ResourcePolicy and the PolicySourceArn is not the ARN for an IAM user. This is required so that the resource-based policy's Principal element has a value to use in evaluating the policy.

type ContextEntries:

list

param ContextEntries:

A list of context keys and corresponding values for the simulation to use. Whenever a context key is evaluated by a Condition element in one of the simulated policies, the corresponding value is supplied.

  • (dict) --

    Contains information about a condition context key. It includes the name of the key and specifies the value (or values, if the context key supports multiple values) to use in the simulation. This information is used when evaluating the Condition elements of the input policies.

    This data type is used as an input parameter to SimulatePolicy.

    • ContextKeyName (string) --

      The full name of a condition context key, including the service prefix. For example, aws:SourceIp or s3:VersionId.

    • ContextKeyValues (list) --

      The value (or values, if the condition context key supports multiple values) to provide to the simulation for use when the key is referenced by a Condition element in an input policy.

      • (string) --

    • ContextKeyType (string) --

      The data type of the value (or values) specified in the ContextKeyValues parameter.

type MaxItems:

integer

param MaxItems:

Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the IsTruncated response element is true.

This parameter is optional. If you do not include it, it defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the IsTruncated response element returns true and Marker contains a value to include in the subsequent call that tells the service where to continue from.

type Marker:

string

param Marker:

Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the Marker element in the response that you received to indicate where the next call should start.

rtype:

dict

returns:

Response Syntax

{
    'EvaluationResults': [
        {
            'EvalActionName': 'string',
            'EvalResourceName': 'string',
            'EvalDecision': 'allowed'|'explicitDeny'|'implicitDeny',
            'MatchedStatements': [
                {
                    'SourcePolicyId': 'string',
                    'SourcePolicyType': 'user'|'group'|'role'|'aws-managed'|'user-managed'|'resource'|'none',
                    'StartPosition': {
                        'Line': 123,
                        'Column': 123
                    },
                    'EndPosition': {
                        'Line': 123,
                        'Column': 123
                    }
                },
            ],
            'MissingContextValues': [
                'string',
            ],
            'EvalDecisionDetails': {
                'string': 'allowed'|'explicitDeny'|'implicitDeny'
            }
        },
    ],
    'IsTruncated': True|False,
    'Marker': 'string'
}

Response Structure

  • (dict) --

    Contains the response to a successful SimulatePrincipalPolicy or SimulateCustomPolicy request.

    • EvaluationResults (list) --

      The results of the simulation.

      • (dict) --

        Contains the results of a simulation.

        This data type is used by the return parameter of SimulatePolicy.

        • EvalActionName (string) --

          The name of the API action tested on the indicated resource.

        • EvalResourceName (string) --

          The ARN of the resource that the indicated API action was tested on.

        • EvalDecision (string) --

          The result of the simulation.

        • MatchedStatements (list) --

          A list of the statements in the input policies that determine the result for this scenario. Remember that even if multiple statements allow the action on the resource, if only one statement denies that action, then the explicit deny overrides any allow, and the deny statement is the only entry included in the result.

          • (dict) --

            Contains a reference to a Statement element in a policy document that determines the result of the simulation.

            This data type is used by the MatchedStatements member of the EvaluationResult type.

            • SourcePolicyId (string) --

              The identifier of the policy that was provided as an input.

            • SourcePolicyType (string) --

              The type of the policy.

            • StartPosition (dict) --

              The row and column of the beginning of the Statement in an IAM policy.

              • Line (integer) --

                The line containing the specified position in the document.

              • Column (integer) --

                The column in the line containing the specified position in the document.

            • EndPosition (dict) --

              The row and column of the end of a Statement in an IAM policy.

              • Line (integer) --

                The line containing the specified position in the document.

              • Column (integer) --

                The column in the line containing the specified position in the document.

        • MissingContextValues (list) --

          A list of context keys that are required by the included input policies but that were not provided by one of the input parameters. To discover the context keys used by a set of policies, you can call GetContextKeysForCustomPolicy or GetContextKeysForPrincipalPolicy.

          If the response includes any keys in this list, then the reported results might be untrustworthy because the simulation could not completely evaluate all of the conditions specified in the policies that would occur in a real world request.

          • (string) --

        • EvalDecisionDetails (dict) --

          Additional details about the results of the evaluation decision. When there are both IAM policies and resource policies, this parameter explains how each set of policies contributes to the final evaluation decision. When simulating cross-account access to a resource, both the resource-based policy and the caller's IAM policy must grant access. See How IAM Roles Differ from Resource-based Policies

          • (string) --

            • (string) --

    • IsTruncated (boolean) --

      A flag that indicates whether there are more items to return. If your results were truncated, you can make a subsequent pagination request using the Marker request parameter to retrieve more items. Note that IAM might return fewer than the MaxItems number of results even when there are more results available. We recommend that you check IsTruncated after every call to ensure that you receive all of your results.

    • Marker (string) --

      When IsTruncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent pagination request.