Skip to content

aws.iam.simulate_custom_policy

Example SQL Queries

SELECT * FROM
aws.iam.simulate_custom_policy
WHERE
"policy_input_list" = 'VALUE'
AND "action_names" = 'VALUE';

Description

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

The simulation does not perform the API operations; it only checks the authorization to determine if the simulated policies allow or deny the operations. You can simulate resources that don't exist in your account.

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

Context keys are variables that are maintained by Amazon Web Services and its services and which 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.

The IAM policy simulator evaluates statements in the identity-based policy and the inputs that you provide during simulation. The policy simulator results can differ from your live Amazon Web Services environment. We recommend that you check your policies against your live Amazon Web Services environment after testing using the policy simulator to confirm that you have the desired results. For more information about using the policy simulator, see Testing IAM policies with the IAM policy simulator in the IAM User Guide.

Table Definition

Column NameColumn Data Type
action_names Required Input Column

A list of names of API operations to evaluate in the simulation. Each operation is evaluated against each resource. Each operation must include the service identifier, such as iam:CreateUser. This operation does not support using wildcards (*) in an action name.

VARCHAR[]
Show child fields
action_names[]
policy_input_list Required Input Column

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 API operations. In other words, do not use policies designed to restrict what a user can do while using the temporary credentials.

The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see IAM and STS character quotas.

The regex pattern used to validate this parameter is a string of characters consisting of the following:

  • Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range

  • The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)

  • The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)

VARCHAR[]
Show child fields
policy_input_list[]
caller_arn Input Column

The ARN of the IAM user that you want to use as the simulated caller of the API operations. 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.

VARCHAR
context_entries Input Column

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

STRUCT(
"context_key_name" VARCHAR,
"context_key_values" VARCHAR[],
"context_key_type" VARCHAR
)[]
Show child fields
context_entries[]
Show child fields
context_entries[].context_key_name

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

context_entries[].context_key_type

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

context_entries[].context_key_values[]
permissions_boundary_policy_input_list Input Column

The IAM permissions boundary policy to simulate. The permissions boundary sets the maximum permissions that an IAM entity can have. You can input only one permissions boundary when you pass a policy to this operation. For more information about permissions boundaries, see Permissions boundaries for IAM entities in the IAM User Guide. The policy input is specified as a string that contains the complete, valid JSON text of a permissions boundary policy.

The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see IAM and STS character quotas.

The regex pattern used to validate this parameter is a string of characters consisting of the following:

  • Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range

  • The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)

  • The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)

VARCHAR[]
Show child fields
permissions_boundary_policy_input_list[]
resource_arns Input Column

A list of ARNs of Amazon Web Services 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. You can simulate resources that don't exist in your account.

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.

For more information about ARNs, see Amazon Resource Names (ARNs) in the Amazon Web Services General Reference.

Simulation of resource-based policies isn't supported for IAM roles.

VARCHAR[]
Show child fields
resource_arns[]
resource_handling_option Input Column

Specifies the type of simulation to run. Different API operations that support resource-based policies require different combinations of resources. By specifying the type of simulation to run, you enable the policy simulator to enforce the presence of the required resources to ensure reliable simulation results. If your simulation does not match one of the following scenarios, then you can omit this parameter. The following list shows each of the supported scenario values and the resources that you must define to run the simulation.

Each of the Amazon EC2 scenarios requires that you specify instance, image, and security group resources. If your scenario includes an EBS volume, then you must specify that volume as a resource. If the Amazon EC2 scenario includes VPC, then you must supply the network interface resource. If it includes an IP subnet, then you must specify the subnet resource. For more information on the Amazon EC2 scenario options, see Supported platforms in the Amazon EC2 User Guide.

  • EC2-VPC-InstanceStore

    instance, image, security group, network interface

  • EC2-VPC-InstanceStore-Subnet

    instance, image, security group, network interface, subnet

  • EC2-VPC-EBS

    instance, image, security group, network interface, volume

  • EC2-VPC-EBS-Subnet

    instance, image, security group, network interface, subnet, volume

VARCHAR
resource_owner Input Column

An ARN representing the Amazon Web Services account ID that specifies the owner of any simulated resource that does not identify its owner in the resource ARN. Examples of resource ARNs include 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.

The ARN for an account uses the following syntax: arn:aws:iam::AWS-account-ID:root. For example, to represent the account with the 112233445566 ID, use the following ARN: arn:aws:iam::112233445566-ID:root.

VARCHAR
resource_policy Input Column

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.

The maximum length of the policy document that you can pass in this operation, including whitespace, is listed below. To view the maximum character counts of a managed policy with no whitespaces, see IAM and STS character quotas.

The regex pattern used to validate this parameter is a string of characters consisting of the following:

  • Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range

  • The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)

  • The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)

Simulation of resource-based policies isn't supported for IAM roles.

VARCHAR
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

eval_action_name

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

VARCHAR
eval_decision

The result of the simulation.

VARCHAR
eval_decision_details

Additional details about the results of the cross-account evaluation decision. This parameter is populated for only cross-account simulations. It contains a brief summary of how each policy type contributes to the final evaluation decision.

If the simulation evaluates policies within the same account and includes a resource ARN, then the parameter is present but the response is empty. If the simulation evaluates policies within the same account and specifies all resources (*), then the parameter is not returned.

When you make a cross-account request, Amazon Web Services evaluates the request in the trusting account and the trusted account. The request is allowed only if both evaluations return true. For more information about how policies are evaluated, see Evaluating policies within a single account.

If an Organizations SCP included in the evaluation denies access, the simulation ends. In this case, policy evaluation does not proceed any further and this parameter is not returned.

MAP(VARCHAR, VARCHAR)
eval_resource_name

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

VARCHAR
matched_statements

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

STRUCT(
"source_policy_id" VARCHAR,
"source_policy_type" VARCHAR,
"start_position" STRUCT(
"line" BIGINT,
"column" BIGINT
),
"end_position" STRUCT(
"line" BIGINT,
"column" BIGINT
)
)[]
Show child fields
matched_statements[]
Show child fields
matched_statements[].end_position

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

Show child fields
matched_statements[].end_position.column

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

matched_statements[].end_position.line

The line containing the specified position in the document.

matched_statements[].source_policy_id

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

matched_statements[].source_policy_type

The type of the policy.

matched_statements[].start_position

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

Show child fields
matched_statements[].start_position.column

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

matched_statements[].start_position.line

The line containing the specified position in the document.

missing_context_values

A list of context keys that are required by the included input policies but that were not provided by one of the input parameters. This list is used when the resource in a simulation is "*", either explicitly, or when the ResourceArns parameter blank. If you include a list of resources, then any missing context values are instead included under the ResourceSpecificResults section. To discover the context keys used by a set of policies, you can call GetContextKeysForCustomPolicy or GetContextKeysForPrincipalPolicy.

VARCHAR[]
Show child fields
missing_context_values[]
organizations_decision_detail

A structure that details how Organizations and its service control policies affect the results of the simulation. Only applies if the simulated user's account is part of an organization.

STRUCT(
"allowed_by_organizations" BOOLEAN
)
Show child fields
organizations_decision_detail.allowed_by_organizations

Specifies whether the simulated operation is allowed by the Organizations service control policies that impact the simulated user's account.

permissions_boundary_decision_detail

Contains information about the effect that a permissions boundary has on a policy simulation when the boundary is applied to an IAM entity.

STRUCT(
"allowed_by_permissions_boundary" BOOLEAN
)
Show child fields
permissions_boundary_decision_detail.allowed_by_permissions_boundary

Specifies whether an action is allowed by a permissions boundary that is applied to an IAM entity (user or role). A value of true means that the permissions boundary does not deny the action. This means that the policy includes an Allow statement that matches the request. In this case, if an identity-based policy also allows the action, the request is allowed. A value of false means that either the requested action is not allowed (implicitly denied) or that the action is explicitly denied by the permissions boundary. In both of these cases, the action is not allowed, regardless of the identity-based policy.

resource_specific_results

The individual results of the simulation of the API operation specified in EvalActionName on each resource.

STRUCT(
"eval_resource_name" VARCHAR,
"eval_resource_decision" VARCHAR,
"matched_statements" STRUCT(
"source_policy_id" VARCHAR,
"source_policy_type" VARCHAR,
"start_position" STRUCT(
"line" BIGINT,
"column" BIGINT
),
"end_position" STRUCT(
"line" BIGINT,
"column" BIGINT
)
)[],
"missing_context_values" VARCHAR[],
"eval_decision_details" MAP(VARCHAR, VARCHAR),
"permissions_boundary_decision_detail" STRUCT(
"allowed_by_permissions_boundary" BOOLEAN
)
)[]
Show child fields
resource_specific_results[]
Show child fields
resource_specific_results[].eval_decision_details

Additional details about the results of the evaluation decision on a single resource. This parameter is returned only for cross-account simulations. This parameter explains how each policy type contributes to the resource-specific evaluation decision.

resource_specific_results[].eval_resource_decision

The result of the simulation of the simulated API operation on the resource specified in EvalResourceName.

resource_specific_results[].eval_resource_name

The name of the simulated resource, in Amazon Resource Name (ARN) format.

resource_specific_results[].matched_statements[]
Show child fields
resource_specific_results[].matched_statements[].end_position

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

Show child fields
resource_specific_results[].matched_statements[].end_position.column

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

resource_specific_results[].matched_statements[].end_position.line

The line containing the specified position in the document.

resource_specific_results[].matched_statements[].source_policy_id

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

resource_specific_results[].matched_statements[].source_policy_type

The type of the policy.

resource_specific_results[].matched_statements[].start_position

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

Show child fields
resource_specific_results[].matched_statements[].start_position.column

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

resource_specific_results[].matched_statements[].start_position.line

The line containing the specified position in the document.

resource_specific_results[].missing_context_values[]
resource_specific_results[].permissions_boundary_decision_detail

Contains information about the effect that a permissions boundary has on a policy simulation when that boundary is applied to an IAM entity.

Show child fields
resource_specific_results[].permissions_boundary_decision_detail.allowed_by_permissions_boundary

Specifies whether an action is allowed by a permissions boundary that is applied to an IAM entity (user or role). A value of true means that the permissions boundary does not deny the action. This means that the policy includes an Allow statement that matches the request. In this case, if an identity-based policy also allows the action, the request is allowed. A value of false means that either the requested action is not allowed (implicitly denied) or that the action is explicitly denied by the permissions boundary. In both of these cases, the action is not allowed, regardless of the identity-based policy.