

# Identity and access management for Amazon Bedrock
<a name="security-iam"></a>

AWS Identity and Access Management (IAM) is an AWS service that helps an administrator securely control access to AWS resources. IAM administrators control who can be *authenticated* (signed in) and *authorized* (have permissions) to use Amazon Bedrock resources. IAM is an AWS service that you can use with no additional charge.

**Topics**
+ [Audience](#security_iam_audience)
+ [Authenticating with identities](#security_iam_authentication)
+ [Managing access using policies](#security_iam_access-manage)
+ [How Amazon Bedrock works with IAM](security_iam_service-with-iam.md)
+ [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md)
+ [IAM policies for Amazon Bedrock Projects](security-iam-projects.md)
+ [AWS managed policies for Amazon Bedrock](security-iam-awsmanpol.md)
+ [Service roles](security-iam-sr.md)
+ [Configure access to Amazon S3 buckets](s3-bucket-access.md)
+ [Troubleshooting Amazon Bedrock identity and access](security_iam_troubleshoot.md)

## Audience
<a name="security_iam_audience"></a>

How you use AWS Identity and Access Management (IAM) differs based on your role:
+ **Service user** - request permissions from your administrator if you cannot access features (see [Troubleshooting Amazon Bedrock identity and access](security_iam_troubleshoot.md))
+ **Service administrator** - determine user access and submit permission requests (see [How Amazon Bedrock works with IAM](security_iam_service-with-iam.md))
+ **IAM administrator** - write policies to manage access (see [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md))

## Authenticating with identities
<a name="security_iam_authentication"></a>

Authentication is how you sign in to AWS using your identity credentials. You must be authenticated as the AWS account root user, an IAM user, or by assuming an IAM role.

You can sign in as a federated identity using credentials from an identity source like AWS IAM Identity Center (IAM Identity Center), single sign-on authentication, or Google/Facebook credentials. For more information about signing in, see [How to sign in to your AWS account](https://docs.aws.amazon.com/signin/latest/userguide/how-to-sign-in.html) in the *AWS Sign-In User Guide*.

For programmatic access, AWS provides an SDK and CLI to cryptographically sign requests. For more information, see [AWS Signature Version 4 for API requests](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html) in the *IAM User Guide*.

### AWS account root user
<a name="security_iam_authentication-rootuser"></a>

 When you create an AWS account, you begin with one sign-in identity called the AWS account *root user* that has complete access to all AWS services and resources. We strongly recommend that you don't use the root user for everyday tasks. For tasks that require root user credentials, see [Tasks that require root user credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks) in the *IAM User Guide*. 

### Federated identity
<a name="security_iam_authentication-federated"></a>

As a best practice, require human users to use federation with an identity provider to access AWS services using temporary credentials.

A *federated identity* is a user from your enterprise directory, web identity provider, or Directory Service that accesses AWS services using credentials from an identity source. Federated identities assume roles that provide temporary credentials.

For centralized access management, we recommend AWS IAM Identity Center. For more information, see [What is IAM Identity Center?](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html) in the *AWS IAM Identity Center User Guide*.

### IAM users and groups
<a name="security_iam_authentication-iamuser"></a>

An *[IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html)* is an identity with specific permissions for a single person or application. We recommend using temporary credentials instead of IAM users with long-term credentials. For more information, see [Require human users to use federation with an identity provider to access AWS using temporary credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-users-federation-idp) in the *IAM User Guide*.

An [https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) specifies a collection of IAM users and makes permissions easier to manage for large sets of users. For more information, see [Use cases for IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/gs-identities-iam-users.html) in the *IAM User Guide*.

### IAM roles
<a name="security_iam_authentication-iamrole"></a>

An *[IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)* is an identity with specific permissions that provides temporary credentials. You can assume a role by [switching from a user to an IAM role (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html) or by calling an AWS CLI or AWS API operation. For more information, see [Methods to assume a role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage-assume.html) in the *IAM User Guide*.

IAM roles are useful for federated user access, temporary IAM user permissions, cross-account access, cross-service access, and applications running on Amazon EC2. For more information, see [Cross account resource access in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html) in the *IAM User Guide*.

## Managing access using policies
<a name="security_iam_access-manage"></a>

You control access in AWS by creating policies and attaching them to AWS identities or resources. A policy defines permissions when associated with an identity or resource. AWS evaluates these policies when a principal makes a request. Most policies are stored in AWS as JSON documents. For more information about JSON policy documents, see [Overview of JSON policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json) in the *IAM User Guide*.

Using policies, administrators specify who has access to what by defining which **principal** can perform **actions** on what **resources**, and under what **conditions**.

By default, users and roles have no permissions. An IAM administrator creates IAM policies and adds them to roles, which users can then assume. IAM policies define permissions regardless of the method used to perform the operation.

### Identity-based policies
<a name="security_iam_access-manage-id-based-policies"></a>

Identity-based policies are JSON permissions policy documents that you attach to an identity (user, group, or role). These policies control what actions identities can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see [Define custom IAM permissions with customer managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html) in the *IAM User Guide*.

Identity-based policies can be *inline policies* (embedded directly into a single identity) or *managed policies* (standalone policies attached to multiple identities). To learn how to choose between managed and inline policies, see [Choose between managed policies and inline policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-choosing-managed-or-inline.html) in the *IAM User Guide*.

### Resource-based policies
<a name="security_iam_access-manage-resource-based-policies"></a>

Resource-based policies are JSON policy documents that you attach to a resource. Examples include IAM *role trust policies* and Amazon S3 *bucket policies*. In services that support resource-based policies, service administrators can use them to control access to a specific resource. You must [specify a principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html) in a resource-based policy.

Resource-based policies are inline policies that are located in that service. You can't use AWS managed policies from IAM in a resource-based policy.

### Other policy types
<a name="security_iam_access-manage-other-policies"></a>

AWS supports additional policy types that can set the maximum permissions granted by more common policy types:
+ **Permissions boundaries** – Set the maximum permissions that an identity-based policy can grant to an IAM entity. For more information, see [Permissions boundaries for IAM entities](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html) in the *IAM User Guide*.
+ **Service control policies (SCPs)** – Specify the maximum permissions for an organization or organizational unit in AWS Organizations. For more information, see [Service control policies](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html) in the *AWS Organizations User Guide*.
+ **Resource control policies (RCPs)** – Set the maximum available permissions for resources in your accounts. For more information, see [Resource control policies (RCPs)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html) in the *AWS Organizations User Guide*.
+ **Session policies** – Advanced policies passed as a parameter when creating a temporary session for a role or federated user. For more information, see [Session policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session) in the *IAM User Guide*.

### Multiple policy types
<a name="security_iam_access-manage-multiple-policies"></a>

When multiple types of policies apply to a request, the resulting permissions are more complicated to understand. To learn how AWS determines whether to allow a request when multiple policy types are involved, see [Policy evaluation logic](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html) in the *IAM User Guide*.

# How Amazon Bedrock works with IAM
<a name="security_iam_service-with-iam"></a>

Before you use IAM to manage access to Amazon Bedrock, learn what IAM features are available to use with Amazon Bedrock.






**IAM features you can use with Amazon Bedrock**  

| IAM feature | Amazon Bedrock support | 
| --- | --- | 
|  [Identity-based policies](#security_iam_service-with-iam-id-based-policies)  |   Yes  | 
|  [Resource-based policies](#security_iam_service-with-iam-resource-based-policies)  |   No   | 
|  [Policy actions](#security_iam_service-with-iam-id-based-policies-actions)  |   Yes  | 
|  [Policy resources](#security_iam_service-with-iam-id-based-policies-resources)  |   Yes  | 
|  [Policy condition keys](#security_iam_service-with-iam-id-based-policies-conditionkeys)  |   Yes  | 
|  [ACLs](#security_iam_service-with-iam-acls)  |   No   | 
|  [ABAC (tags in policies)](#security_iam_service-with-iam-tags)  |   Yes  | 
|  [Temporary credentials](#security_iam_service-with-iam-roles-tempcreds)  |   Yes  | 
|  [Principal permissions](#security_iam_service-with-iam-principal-permissions)  |   Yes  | 
|  [Service roles](#security_iam_service-with-iam-roles-service)  |   Yes  | 
|  [Service-linked roles](#security_iam_service-with-iam-roles-service-linked)  |   No   | 

To get a high-level view of how Amazon Bedrock and other AWS services work with most IAM features, see [AWS services that work with IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html) in the *IAM User Guide*.

## Identity-based policies for Amazon Bedrock
<a name="security_iam_service-with-iam-id-based-policies"></a>

**Supports identity-based policies:** Yes

Identity-based policies are JSON permissions policy documents that you can attach to an identity, such as an IAM user, group of users, or role. These policies control what actions users and roles can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see [Define custom IAM permissions with customer managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html) in the *IAM User Guide*.

With IAM identity-based policies, you can specify allowed or denied actions and resources as well as the conditions under which actions are allowed or denied. To learn about all of the elements that you can use in a JSON policy, see [IAM JSON policy elements reference](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html) in the *IAM User Guide*.

### Identity-based policy examples for Amazon Bedrock
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



To view examples of Amazon Bedrock identity-based policies, see [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md).

## Resource-based policies within Amazon Bedrock
<a name="security_iam_service-with-iam-resource-based-policies"></a>

**Supports resource-based policies:** No 

Resource-based policies are JSON policy documents that you attach to a resource. Examples of resource-based policies are IAM *role trust policies* and Amazon S3 *bucket policies*. In services that support resource-based policies, service administrators can use them to control access to a specific resource. For the resource where the policy is attached, the policy defines what actions a specified principal can perform on that resource and under what conditions. You must [specify a principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html) in a resource-based policy. Principals can include accounts, users, roles, federated users, or AWS services.

To enable cross-account access, you can specify an entire account or IAM entities in another account as the principal in a resource-based policy. For more information, see [Cross account resource access in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html) in the *IAM User Guide*.

## Policy actions for Amazon Bedrock
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

**Supports policy actions:** Yes

Administrators can use AWS JSON policies to specify who has access to what. That is, which **principal** can perform **actions** on what **resources**, and under what **conditions**.

The `Action` element of a JSON policy describes the actions that you can use to allow or deny access in a policy. Include actions in a policy to grant permissions to perform the associated operation.



To see a list of Amazon Bedrock actions, see [Actions defined by Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-actions-as-permissions) in the *Service Authorization Reference*.

Policy actions in Amazon Bedrock use the following prefix before the action:

```
bedrock
```

To specify multiple actions in a single statement, separate them with commas.

```
"Action": [
   "bedrock:action1",
   "bedrock:action2"
]
```





To view examples of Amazon Bedrock identity-based policies, see [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md).

## Policy resources for Amazon Bedrock
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

**Supports policy resources:** Yes

Administrators can use AWS JSON policies to specify who has access to what. That is, which **principal** can perform **actions** on what **resources**, and under what **conditions**.

The `Resource` JSON policy element specifies the object or objects to which the action applies. As a best practice, specify a resource using its [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html). For actions that don't support resource-level permissions, use a wildcard (\$1) to indicate that the statement applies to all resources.

```
"Resource": "*"
```

To see a list of Amazon Bedrock resource types and their ARNs, see [Resources defined by Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-resources-for-iam-policies) in the *Service Authorization Reference*. To learn with which actions you can specify the ARN of each resource, see [Actions defined by Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-actions-as-permissions).





Some Amazon Bedrock API actions support multiple resources. For example, [AssociateAgentKnowledgeBase](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_AssociateAgentKnowledgeBase.html) accesses *AGENT12345* and *KB12345678*, so a principal must have permissions to access both resources. To specify multiple resources in a single statement, separate the ARNs with commas. 

```
"Resource": [
   "arn:aws:bedrock:aws-region:111122223333:agent/AGENT12345",
   "arn:aws:bedrock:aws-region:111122223333:knowledge-base/KB12345678"
]
```

To view examples of Amazon Bedrock identity-based policies, see [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md).

## Policy condition keys for Amazon Bedrock
<a name="security_iam_service-with-iam-id-based-policies-conditionkeys"></a>

**Supports service-specific policy condition keys:** Yes

Administrators can use AWS JSON policies to specify who has access to what. That is, which **principal** can perform **actions** on what **resources**, and under what **conditions**.

The `Condition` element specifies when statements execute based on defined criteria. You can create conditional expressions that use [condition operators](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html), such as equals or less than, to match the condition in the policy with values in the request. To see all AWS global condition keys, see [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) in the *IAM User Guide*.

To see a list of Amazon Bedrock condition keys, see [Condition Keys for Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) in the *Service Authorization Reference*. To learn with which actions and resources you can use a condition key, see [Actions defined by Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-actions-as-permissions).

All Amazon Bedrock actions support condition keys using Amazon Bedrock models as the resource.

To view examples of Amazon Bedrock identity-based policies, see [Identity-based policy examples for Amazon Bedrock](security_iam_id-based-policy-examples.md).

## ACLs in Amazon Bedrock
<a name="security_iam_service-with-iam-acls"></a>

**Supports ACLs:** No 

Access control lists (ACLs) control which principals (account members, users, or roles) have permissions to access a resource. ACLs are similar to resource-based policies, although they do not use the JSON policy document format.

## ABAC with Amazon Bedrock
<a name="security_iam_service-with-iam-tags"></a>

**Supports ABAC (tags in policies):** Yes

Attribute-based access control (ABAC) is an authorization strategy that defines permissions based on attributes called tags. You can attach tags to IAM entities and AWS resources, then design ABAC policies to allow operations when the principal's tag matches the tag on the resource.

To control access based on tags, you provide tag information in the [condition element](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html) of a policy using the `aws:ResourceTag/key-name`, `aws:RequestTag/key-name`, or `aws:TagKeys` condition keys.

If a service supports all three condition keys for every resource type, then the value is **Yes** for the service. If a service supports all three condition keys for only some resource types, then the value is **Partial**.

For more information about ABAC, see [Define permissions with ABAC authorization](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html) in the *IAM User Guide*. To view a tutorial with steps for setting up ABAC, see [Use attribute-based access control (ABAC)](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html) in the *IAM User Guide*.

## Using temporary credentials with Amazon Bedrock
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

**Supports temporary credentials:** Yes

Temporary credentials provide short-term access to AWS resources and are automatically created when you use federation or switch roles. AWS recommends that you dynamically generate temporary credentials instead of using long-term access keys. For more information, see [Temporary security credentials in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) and [AWS services that work with IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html) in the *IAM User Guide*.

## Cross-service principal permissions for Amazon Bedrock
<a name="security_iam_service-with-iam-principal-permissions"></a>

**Supports forward access sessions (FAS):** Yes

 Forward access sessions (FAS) use the permissions of the principal calling an AWS service, combined with the requesting AWS service to make requests to downstream services. For policy details when making FAS requests, see [Forward access sessions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html). 

## Service roles for Amazon Bedrock
<a name="security_iam_service-with-iam-roles-service"></a>

**Supports service roles:** Yes

 A service role is an [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) that a service assumes to perform actions on your behalf. An IAM administrator can create, modify, and delete a service role from within IAM. For more information, see [Create a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) in the *IAM User Guide*. 

**Warning**  
Changing the permissions for a service role might break Amazon Bedrock functionality. Edit service roles only when Amazon Bedrock provides guidance to do so.

## Service-linked roles for Amazon Bedrock
<a name="security_iam_service-with-iam-roles-service-linked"></a>

**Supports service-linked roles:** No 

 A service-linked role is a type of service role that is linked to an AWS service. The service can assume the role to perform an action on your behalf. Service-linked roles appear in your AWS account and are owned by the service. An IAM administrator can view, but not edit the permissions for service-linked roles. 

# Identity-based policy examples for Amazon Bedrock
<a name="security_iam_id-based-policy-examples"></a>

By default, users and roles don't have permission to create or modify Amazon Bedrock resources. To grant users permission to perform actions on the resources that they need, an IAM administrator can create IAM policies.

To learn how to create an IAM identity-based policy by using these example JSON policy documents, see [Create IAM policies (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) in the *IAM User Guide*.

For details about actions and resource types defined by Amazon Bedrock, including the format of the ARNs for each of the resource types, see [Actions, Resources, and Condition Keys for Amazon Bedrock ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html) in the *Service Authorization Reference*.

**Topics**
+ [Policy best practices](#security_iam_service-with-iam-policy-best-practices)
+ [Use the Amazon Bedrock console](#security_iam_id-based-policy-examples-console)
+ [Allow users to view their own permissions](#security_iam_id-based-policy-examples-view-own-permissions)
+ [Deny access for inference of foundation models](#security_iam_id-based-policy-examples-deny-inference)
+ [Allow users to invoke a provisioned model](#security_iam_id-based-policy-examples-perform-actions-pt)
+ [Identity-based policy examples for Amazon Bedrock Agents](security_iam_id-based-policy-examples-agent.md)

## Policy best practices
<a name="security_iam_service-with-iam-policy-best-practices"></a>

Identity-based policies determine whether someone can create, access, or delete Amazon Bedrock resources in your account. These actions can incur costs for your AWS account. When you create or edit identity-based policies, follow these guidelines and recommendations:
+ **Get started with AWS managed policies and move toward least-privilege permissions** – To get started granting permissions to your users and workloads, use the *AWS managed policies* that grant permissions for many common use cases. They are available in your AWS account. We recommend that you reduce permissions further by defining AWS customer managed policies that are specific to your use cases. For more information, see [AWS managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies) or [AWS managed policies for job functions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html) in the *IAM User Guide*.
+ **Apply least-privilege permissions** – When you set permissions with IAM policies, grant only the permissions required to perform a task. You do this by defining the actions that can be taken on specific resources under specific conditions, also known as *least-privilege permissions*. For more information about using IAM to apply permissions, see [ Policies and permissions in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html) in the *IAM User Guide*.
+ **Use conditions in IAM policies to further restrict access** – You can add a condition to your policies to limit access to actions and resources. For example, you can write a policy condition to specify that all requests must be sent using SSL. You can also use conditions to grant access to service actions if they are used through a specific AWS service, such as CloudFormation. For more information, see [ IAM JSON policy elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html) in the *IAM User Guide*.
+ **Use IAM Access Analyzer to validate your IAM policies to ensure secure and functional permissions** – IAM Access Analyzer validates new and existing policies so that the policies adhere to the IAM policy language (JSON) and IAM best practices. IAM Access Analyzer provides more than 100 policy checks and actionable recommendations to help you author secure and functional policies. For more information, see [Validate policies with IAM Access Analyzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-validation.html) in the *IAM User Guide*.
+ **Require multi-factor authentication (MFA)** – If you have a scenario that requires IAM users or a root user in your AWS account, turn on MFA for additional security. To require MFA when API operations are called, add MFA conditions to your policies. For more information, see [ Secure API access with MFA](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html) in the *IAM User Guide*.

For more information about best practices in IAM, see [Security best practices in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) in the *IAM User Guide*.

## Use the Amazon Bedrock console
<a name="security_iam_id-based-policy-examples-console"></a>

To access the Amazon Bedrock console, you must have a minimum set of permissions. These permissions must allow you to list and view details about the Amazon Bedrock resources in your AWS account. If you create an identity-based policy that is more restrictive than the minimum required permissions, the console won't function as intended for entities (users or roles) with that policy.

You don't need to allow minimum console permissions for users that are making calls only to the AWS CLI or the AWS API. Instead, allow access to only the actions that match the API operation that they're trying to perform.

To ensure that users and roles can still use the Amazon Bedrock console, also attach the Amazon Bedrock [AmazonBedrockFullAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonBedrockFullAccess) or [AmazonBedrockReadOnly](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonBedrockReadOnly) AWS managed policy to the entities. For more information, see [Adding permissions to a user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_change-permissions.html#users_change_permissions-add-console) in the *IAM User Guide*.

## Allow users to view their own permissions
<a name="security_iam_id-based-policy-examples-view-own-permissions"></a>

This example shows how you might create a policy that allows IAM users to view the inline and managed policies that are attached to their user identity. This policy includes permissions to complete this action on the console or programmatically using the AWS CLI or AWS API.

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ViewOwnUserInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetUserPolicy",
                "iam:ListGroupsForUser",
                "iam:ListAttachedUserPolicies",
                "iam:ListUserPolicies",
                "iam:GetUser"
            ],
            "Resource": ["arn:aws:iam::*:user/${aws:username}"]
        },
        {
            "Sid": "NavigateInConsole",
            "Effect": "Allow",
            "Action": [
                "iam:GetGroupPolicy",
                "iam:GetPolicyVersion",
                "iam:GetPolicy",
                "iam:ListAttachedGroupPolicies",
                "iam:ListGroupPolicies",
                "iam:ListPolicyVersions",
                "iam:ListPolicies",
                "iam:ListUsers"
            ],
            "Resource": "*"
        }
    ]
}
```

## Deny access for inference of foundation models
<a name="security_iam_id-based-policy-examples-deny-inference"></a>

To prevent a user from invoking foundation models, you need to deny access to API actions that invoke models directly. The following example shows a identity-based policy that denies access to running inference on a specific model. This policy can be used as a service control policy (SCP) to control model access across an organization.

------
#### [ JSON ]

****  

```
{
          "Version":"2012-10-17",		 	 	 
          "Statement": {
              "Sid": "DenyInference",
              "Effect": "Deny",
              "Action": [
                  "bedrock:InvokeModel",
                  "bedrock:InvokeModelWithResponseStream",
                  "bedrock:CreateModelInvocationJob"
               ],
              "Resource": "arn:aws:bedrock:*::foundation-model/model-id"
          }
      }
```

------

To deny inference access to all foundation models, use `*` for the model ID. Other actions, such as `Converse` and `StartAsyncInvoke`, are blocked automatically when `InvokeModel` is denied. For a list of model IDs, see [Supported foundation models in Amazon Bedrock](models-supported.md)

## Allow users to invoke a provisioned model
<a name="security_iam_id-based-policy-examples-perform-actions-pt"></a>

The following is a sample policy that you can attach to an IAM role to allow it to use a provisioned model in model inference. For example, you could attach this policy to a role that you want to only have permissions to use a provisioned model. The role won't be able to manage or see information about the Provisioned Throughput.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ProvisionedThroughputModelInvocation",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream"
            ],
            "Resource": "arn:aws:bedrock:us-east-1:123456789012:provisioned-model/my-provisioned-model"
        }
    ]
}
```

------

# Identity-based policy examples for Amazon Bedrock Agents
<a name="security_iam_id-based-policy-examples-agent"></a>

Select a topic to see example IAM policies that you can attach to an IAM role to provision permissions for actions in [Automate tasks in your application using AI agents](agents.md).

**Topics**
+ [Required permissions for Amazon Bedrock Agents](#iam-agents-ex-all)
+ [Allow users to view information about and invoke an agent](#security_iam_id-based-policy-examples-perform-actions-agent)
+ [Control access to service tiers](#security_iam_id-based-policy-examples-service-tiers)

## Required permissions for Amazon Bedrock Agents
<a name="iam-agents-ex-all"></a>

For an IAM identity to use Amazon Bedrock Agents, you must configure it with the necessary permissions. You can attach the [AmazonBedrockFullAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonBedrockFullAccess) policy to grant the proper permissions to the role.

To restrict permissions to only actions that are used in Amazon Bedrock Agents, attach the following identity-based policy to an IAM role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AgentPermissions",
            "Effect": "Allow",
            "Action": [  
                "bedrock:ListFoundationModels",
                "bedrock:GetFoundationModel",
                "bedrock:TagResource", 
                "bedrock:UntagResource", 
                "bedrock:ListTagsForResource", 
                "bedrock:CreateAgent", 
                "bedrock:UpdateAgent", 
                "bedrock:GetAgent", 
                "bedrock:ListAgents", 
                "bedrock:DeleteAgent",
                "bedrock:CreateAgentActionGroup", 
                "bedrock:UpdateAgentActionGroup", 
                "bedrock:GetAgentActionGroup", 
                "bedrock:ListAgentActionGroups", 
                "bedrock:DeleteAgentActionGroup",
                "bedrock:GetAgentVersion",
                "bedrock:ListAgentVersions", 
                "bedrock:DeleteAgentVersion",
                "bedrock:CreateAgentAlias", 
                "bedrock:UpdateAgentAlias",               
                "bedrock:GetAgentAlias",
                "bedrock:ListAgentAliases",
                "bedrock:DeleteAgentAlias",
                "bedrock:AssociateAgentKnowledgeBase",
                "bedrock:DisassociateAgentKnowledgeBase",
                "bedrock:ListAgentKnowledgeBases",
                "bedrock:GetKnowledgeBase",
                "bedrock:ListKnowledgeBases",
                "bedrock:PrepareAgent",
                "bedrock:InvokeAgent",
                "bedrock:AssociateAgentCollaborator",
                "bedrock:DisassociateAgentCollaborator",
                "bedrock:GetAgentCollaborator",
                "bedrock:ListAgentCollaborators",
                "bedrock:UpdateAgentCollaborator"
            ],
            "Resource": "*"
        }
    ]   
}
```

------

You can further restrict permissions by omitting [actions](security_iam_service-with-iam.md#security_iam_service-with-iam-id-based-policies-actions) or specifying [resources](security_iam_service-with-iam.md#security_iam_service-with-iam-id-based-policies-resources) and [condition keys](security_iam_service-with-iam.md#security_iam_service-with-iam-id-based-policies-conditionkeys). An IAM identity can call API operations on specific resources. For example, the [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgent.html) operation can only be used on agent resources and the [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) operation can only be used on alias resources. For API operations that aren't used on a specific resource type (such as [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgent.html)), specify \$1 as the `Resource`. If you specify an API operation that can't be used on the resource specified in the policy, Amazon Bedrock returns an error.

## Allow users to view information about and invoke an agent
<a name="security_iam_id-based-policy-examples-perform-actions-agent"></a>

The following is a sample policy that you can attach to an IAM role to allow it to view information about or edit an agent with the ID *AGENT12345* and to interact with its alias with the ID *ALIAS12345*. For example, you could attach this policy to a role that you want to only have permissions to troubleshoot an agent and update it.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetAndUpdateAgent",
            "Effect": "Allow",
            "Action": [
                "bedrock:GetAgent",
                "bedrock:UpdateAgent"
            ],
            "Resource": "arn:aws:bedrock:us-east-1:123456789012:agent/AgentId"
        },
        {
            "Sid": "InvokeAgent",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeAgent"
            ],
            "Resource": "arn:aws:bedrock:us-east-1:123456789012:agent-alias/AgentId/AgentAliasId"
        }
    ]
}
```

------

## Control access to service tiers
<a name="security_iam_id-based-policy-examples-service-tiers"></a>

Amazon Bedrock service tiers provide different levels of processing priority and pricing for inference requests. By default, all service tiers (priority, default, and flex) are available to users with proper Bedrock permissions, following an allowlist approach where access is granted unless explicitly restricted.

However, organizations may want to control which service tiers their users can access to manage costs or enforce usage policies. You can implement access restrictions by using IAM policies with the `bedrock:ServiceTier` condition key to deny access to specific service tiers. This approach allows you to maintain granular control over which team members can use premium service tiers like "priority" or cost-optimized tiers like "flex".

The following example shows an identity-based policy that denies access to all service tiers. This type of policy is useful when you want to prevent users from specifying any service tier, forcing them to use the system default behavior:

```
{
    "Version": "2012-10-17", 		 	 	 
    "Statement": [
        {
            "Effect": "Deny",
            "Action": "bedrock:InvokeModel",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "bedrock:ServiceTier": ["reserved", "priority", "default", "flex"]
                }
            }
        }
    ]
}
```

You can customize this policy to deny access to only specific service tiers by modifying the `bedrock:ServiceTier` condition values. For example, to deny only the premium "priority" tier while allowing "default" and "flex", you would specify only `["priority"]` in the condition. This flexible approach allows you to implement usage policies that align with your organization's cost management and operational requirements. For more information about service tiers, see [Service tiers for optimizing performance and cost](service-tiers-inference.md).

# IAM policies for Amazon Bedrock Projects
<a name="security-iam-projects"></a>

You can use IAM policies to control access to Amazon Bedrock Projects resources. These are standard IAM identity-based policies that you attach to IAM users, groups, or roles. The policies use the `Resource` element to scope permissions to specific project ARNs. For general information about creating and managing IAM policies, see [Managing IAM policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage.html) in the *IAM User Guide*.

## Example IAM policies for Projects
<a name="security-iam-projects-examples"></a>

The following examples show IAM policy documents that grant access to Bedrock Projects resources. Attach these policies to IAM users, groups, or roles using the IAM console, CLI, or API.

### Read-only access to a project
<a name="security-iam-projects-readonly"></a>

The following policy grants read-only access to a specific project:

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ReadOnlyProjectAccess",
            "Effect": "Allow",
            "Action": [
                "bedrock-mantle:GetProject",
                "bedrock-mantle:ListProjects",
                "bedrock-mantle:ListTagsForResources",
                "bedrock-mantle:CreateInference"
            ],
            "Resource": "arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123"
        }
    ]
}
```

### Full access to a project
<a name="security-iam-projects-full-access"></a>

The following policy grants full access to all Bedrock Projects actions on a specific project:

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "FullProjectAccess",
            "Effect": "Allow",
            "Action": "bedrock-mantle:*",
            "Resource": "arn:aws:bedrock-mantle:us-east-1:123456789012:project/proj_abc123"
        }
    ]
}
```







# AWS managed policies for Amazon Bedrock
<a name="security-iam-awsmanpol"></a>

To add permissions to users, groups, and roles, it's easier to use AWS managed policies than to write policies yourself. It takes time and expertise to [create IAM customer managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) that provide your team with only the permissions they need. To get started quickly, you can use our AWS managed policies. These policies cover common use cases and are available in your AWS account.

For a list of AWS managed policies, see [AWS managed policies](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/policy-list.html) in the AWS managed policy referenc. For more information about AWS managed policies, see [AWS managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies) in the *IAM User Guide*.

AWS services maintain and update AWS managed policies. You can't change the permissions in AWS managed policies. Services occasionally add additional permissions to an AWS managed policy to support new features. This type of update affects all identities (users, groups, and roles) where the policy is attached. Services are most likely to update an AWS managed policy when a new feature is launched or when new operations become available. Services do not remove permissions from an AWS managed policy, so policy updates won't break your existing permissions.

Additionally, AWS supports managed policies for job functions that span multiple services. For example, the **ReadOnlyAccess** AWS managed policy provides read-only access to all AWS services and resources. When a service launches a new feature, AWS adds read-only permissions for new operations and resources. For a list and descriptions of job function policies, see [AWS managed policies for job functions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html) in the *IAM User Guide*.

**Topics**
+ [AWS managed policy: AmazonBedrockFullAccess](#security-iam-awsmanpol-AmazonBedrockFullAccess)
+ [AWS managed policy: AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly)
+ [AWS managed policy: AmazonBedrockLimitedAccess](#security-iam-awsmanpol-AmazonBedrockLimitedAccess)
+ [AWS managed policy: AmazonBedrockMarketplaceAccess](#security-iam-awsmanpol-AmazonBedrockMarketplaceAccess)
+ [AWS managed policy: AmazonBedrockMantleFullAccess](#security-iam-awsmanpol-AmazonBedrockMantleFullAccess)
+ [AWS managed policy: AmazonBedrockMantleReadOnly](#security-iam-awsmanpol-AmazonBedrockMantleReadOnly)
+ [AWS managed policy: AmazonBedrockMantleInferenceAccess](#security-iam-awsmanpol-AmazonBedrockMantleInferenceAccess)
+ [Amazon Bedrock updates to AWS managed policies](#security-iam-awsmanpol-updates)

## AWS managed policy: AmazonBedrockFullAccess
<a name="security-iam-awsmanpol-AmazonBedrockFullAccess"></a>

You can attach the [AmazonBedrockFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockFullAccess.html) policy to your IAM identities to grant administrative permissions that allow the user permission to create, read, update, and delete Amazon Bedrock resources.

**Permissions details**

This policy includes the following permissions:
+  `ec2` (Amazon Elastic Compute Cloud) – Allows permissions to describe VPCs, subnets, and security groups. 
+  `iam` (AWS Identity and Access Management) – Allows principals to pass roles, but only allows IAM roles with "Amazon Bedrock" in them to be passed to the Amazon Bedrock service. The permissions are restricted to `bedrock.amazonaws.com` for Amazon Bedrock operations. 
+  `kms` (AWS Key Management Service) – Allows principals to describe AWS KMS keys and aliases. 
+  `bedrock` (Amazon Bedrock) – Allows principals read and write access to all actions in the Amazon Bedrock control plane and runtime service. 
+  `sagemaker` (Amazon SageMaker AI) – Allows principals to access the Amazon SageMaker AI resources in the customer's account, which serves as the foundation for the Amazon Bedrock Marketplace feature. 

------
#### [ JSON ]

****  

```
{
     "Version":"2012-10-17",		 	 	 
     "Statement": [
         {
             "Sid": "BedrockAll",
             "Effect": "Allow",
             "Action": [
                 "bedrock:*"
             ],
             "Resource": "*"
         },
         {
             "Sid": "DescribeKey",
             "Effect": "Allow",
             "Action": [
                 "kms:DescribeKey"
             ],
             "Resource": "arn:*:kms:*:::*"
         },
         {
             "Sid": "APIsWithAllResourceAccess",
             "Effect": "Allow",
             "Action": [
                 "iam:ListRoles",
                 "ec2:DescribeVpcs",
                 "ec2:DescribeSubnets",
                 "ec2:DescribeSecurityGroups"
             ],
             "Resource": "*"
         },
         {
             "Sid": "MarketplaceModelEndpointMutatingAPIs",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:CreateEndpoint",
                 "sagemaker:CreateEndpointConfig",
                 "sagemaker:CreateModel",
                 "sagemaker:DeleteEndpoint",
                 "sagemaker:UpdateEndpoint"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:*:endpoint/*",
                 "arn:aws:sagemaker:*:*:endpoint-config/*",
                 "arn:aws:sagemaker:*:*:model/*"
             ],
             "Condition": {
                 "StringEquals": {
                     "aws:CalledViaLast": "bedrock.amazonaws.com",
                     "aws:ResourceTag/sagemaker-sdk:bedrock": "compatible"
                 }
             }
         },
         {
             "Sid": "MarketplaceModelEndpointAddTagsOperations",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:AddTags"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:*:endpoint/*",
                 "arn:aws:sagemaker:*:*:endpoint-config/*",
                 "arn:aws:sagemaker:*:*:model/*"
             ],
             "Condition": {
                 "ForAllValues:StringEquals": {
                     "aws:TagKeys": [
                         "sagemaker-sdk:bedrock",
                         "bedrock:marketplace-registration-status",
                         "sagemaker-studio:hub-content-arn"
                     ]
                 },
                 "StringLike": {
                     "aws:RequestTag/sagemaker-sdk:bedrock": "compatible",
                     "aws:RequestTag/bedrock:marketplace-registration-status": "registered",
                     "aws:RequestTag/sagemaker-studio:hub-content-arn": "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/*"
                 }
             }
         },
         {
             "Sid": "MarketplaceModelEndpointDeleteTagsOperations",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:DeleteTags"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:*:endpoint/*",
                 "arn:aws:sagemaker:*:*:endpoint-config/*",
                 "arn:aws:sagemaker:*:*:model/*"
             ],
             "Condition": {
                 "ForAllValues:StringEquals": {
                     "aws:TagKeys": [
                         "sagemaker-sdk:bedrock",
                         "bedrock:marketplace-registration-status",
                         "sagemaker-studio:hub-content-arn"
                     ]
                 },
                 "StringLike": {
                     "aws:ResourceTag/sagemaker-sdk:bedrock": "compatible",
                     "aws:ResourceTag/bedrock:marketplace-registration-status": "registered",
                     "aws:ResourceTag/sagemaker-studio:hub-content-arn": "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/*"
                 }
             }
         },
         {
             "Sid": "MarketplaceModelEndpointNonMutatingAPIs",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:DescribeEndpoint",
                 "sagemaker:DescribeEndpointConfig",
                 "sagemaker:DescribeModel",
                 "sagemaker:DescribeInferenceComponent",
                 "sagemaker:ListEndpoints",
                 "sagemaker:ListTags"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:*:endpoint/*",
                 "arn:aws:sagemaker:*:*:endpoint-config/*",
                 "arn:aws:sagemaker:*:*:model/*"
             ],
             "Condition": {
                 "StringEquals": {
                     "aws:CalledViaLast": "bedrock.amazonaws.com"
                 }
             }
         },
         {
             "Sid": "MarketplaceModelEndpointInvokingOperations",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:InvokeEndpoint",
                 "sagemaker:InvokeEndpointWithResponseStream"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:*:endpoint/*"
             ],
             "Condition": {
                 "StringEquals": {
                     "aws:CalledViaLast": "bedrock.amazonaws.com",
                     "aws:ResourceTag/sagemaker-sdk:bedrock": "compatible"
                 }
             }
         },
         {
             "Sid": "DiscoveringMarketplaceModel",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:DescribeHubContent"
             ],
             "Resource": [
                 "arn:aws:sagemaker:*:aws:hub-content/SageMakerPublicHub/Model/*",
                 "arn:aws:sagemaker:*:aws:hub/SageMakerPublicHub"
             ]
         },
         {
             "Sid": "AllowMarketplaceModelsListing",
             "Effect": "Allow",
             "Action": [
                 "sagemaker:ListHubContents"
             ],
             "Resource": "arn:aws:sagemaker:*:aws:hub/SageMakerPublicHub"
         },
         {
             "Sid": "PassRoleToSageMaker",
             "Effect": "Allow",
             "Action": [
                 "iam:PassRole"
             ],
             "Resource": [
                 "arn:aws:iam::*:role/*SageMaker*ForBedrock*"
             ],
             "Condition": {
                 "StringEquals": {
                     "iam:PassedToService": [
                         "sagemaker.amazonaws.com",
                         "bedrock.amazonaws.com"
                     ]
                 }
             }
         },
         {
             "Sid": "PassRoleToBedrock",
             "Effect": "Allow",
             "Action": [
                 "iam:PassRole"
             ],
             "Resource": "arn:aws:iam::*:role/*AmazonBedrock*",
             "Condition": {
                 "StringEquals": {
                     "iam:PassedToService": [
                         "bedrock.amazonaws.com"
                     ]
                 }
             }
         },
         {
             "Sid": "MarketplaceOperationsFromBedrockFor3pModels",
             "Effect": "Allow",
             "Action": [
                 "aws-marketplace:Subscribe",
                 "aws-marketplace:ViewSubscriptions",
                 "aws-marketplace:Unsubscribe"
             ],
             "Resource": "*",
             "Condition": {
                 "StringEquals": {
                     "aws:CalledViaLast": "bedrock.amazonaws.com"
                 }
             }
         }
     ]
 }
```

------

## AWS managed policy: AmazonBedrockReadOnly
<a name="security-iam-awsmanpol-AmazonBedrockReadOnly"></a>

You can attach the [AmazonBedrockReadOnly](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockReadOnly.html) policy to your IAM identities to grant read-only permissions to view all resources in Amazon Bedrock.

## AWS managed policy: AmazonBedrockLimitedAccess
<a name="security-iam-awsmanpol-AmazonBedrockLimitedAccess"></a>

You can attach the [AmazonBedrockLimitedAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockLimitedAccess.html) policy to your IAM identities to allow it access to Amazon Bedrock services, AWS KMS key management, networking resources, and AWS Marketplace subscriptions for third-party foundation models. The policy includes the following statements:
+ The `BedrockAPIs` statement allows you to perform several operations in Amazon Bedrock including:
  + Passing the Amazon Bedrock API key when making API requests to the Amazon Bedrock service.
  + Describing information about resources.
  + Creating resources (guardrails, models, jobs).
  + Creating and refining Automated Reasoning policies (create, build, refine, and test policies).
  + Deleting resources.
  + Invoking models on all resources.
+ The `DescribeKey` statement allows you to view information about KMS keys across all regions and accounts, as long as the policies on the keys permit you to do so.
+ The `APIsWithAllResourceAccess` statement allows you to:
  + List IAM roles.
  + Describe Amazon VPC resources (VPCs, subnets, and security groups) across all resources.
+ The `MarketplaceOperationsFromBedrockFor3pModels` statement enables you to:
  + Subscribe to AWS Marketplace offerings.
  + View subscriptions.
  + Unsubscribe from AWS Marketplace offerings.
**Note**  
The condition key `aws:CalledViaLast` restricts these actions to only when they are called through the Amazon Bedrock service.

## AWS managed policy: AmazonBedrockMarketplaceAccess
<a name="security-iam-awsmanpol-AmazonBedrockMarketplaceAccess"></a>

You can attach the [AmazonBedrockMarketplaceAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockMarketplaceAccess.html) policy to your IAM identities to allow it to manage and use Amazon Bedrock marketplace model endpoints with SageMaker AI integration. The policy includes the following statements:
+ The `BedrockMarketplaceAPIs` statement allows you to create, delete, register, deregister, and update marketplace model endpoints in Amazon Bedrock on all resources.
+ The `MarketplaceModelEndpointMutatingAPIs` statement allows you to create and manage SageMaker AI endpoints, endpoint configurations, and models on specified resources.
  + Use the `aws:CalledViaLast` condition key to ensure that these actions are only performed when called through Bedrock.
  + Use the `aws:ResourceTag/sagemaker-sdk:bedrock` condition key to ensure that these actions are only performed on resources tagged as Amazon Bedrock-compatible.
+ The `MarketplaceModelEndpointAddTagsOperations` statement allows adding specific tags to SageMaker AI endpoints, endpoint configurations, and models on specified resources.
  + Use the `aws:TagKeys` condition key to restrict which tags can be added
  + Use the `aws:RequestTag/*` condition key to ensure tag values match specified patterns
+ The `MarketplaceModelEndpointDeleteTagsOperations` statement allows deleting specific tags from SageMaker AI endpoints, endpoint configurations, and models on specified resources.
  + Use the `aws:TagKeys` condition key to restrict which tags can be deleted
  + Use the `aws:ResourceTag/*` condition key to ensure deleted tags match specified patterns
+ The `MarketplaceModelEndpointNonMutatingAPIs` statement allows viewing and describing SageMaker AI endpoints, endpoint configurations, and models on specified resources.
  + Use `aws:CalledViaLast` condition key to ensure actions are only performed through the Amazon Bedrock service
+ The `MarketplaceModelEndpointInvokingOperations` statement allows invoking SageMaker AI endpoints on specified resources.
  + Use the `aws:CalledViaLast` condition key to ensure actions are only performed through the Amazon Bedrock service
  + Use the `aws:ResourceTag/sagemaker-sdk:bedrock` condition key to ensure actions are only performed on Bedrock-compatible resources
+ The `DiscoveringMarketplaceModel` statement allows decribing SageMaker AI hub content on specified resources.
+ The `AllowMarketplaceModelsListing` statement allows listing SageMaker AI hub contents on specified resources.
+ The `PassRoleToSageMaker` statement allows passing IAM roles to SageMaker AI and Amazon Bedrock on specified resources.
  + Use `iam:PassedToService` condition key to ensure roles are only passed to specified services.
+ The `PassRoleToBedrock` statement allows you to pass specific IAM roles to Amazon Bedrock on specified resources.
  + Use the `iam:PassedToService` condition key to ensure roles are only passed to the Amazon Bedrock service.

## AWS managed policy: AmazonBedrockMantleFullAccess
<a name="security-iam-awsmanpol-AmazonBedrockMantleFullAccess"></a>

You can attach the [AmazonBedrockMantleFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockMantleFullAccess.html) policy to your IAM identities to grant full access to all Amazon Bedrock Mantle operations.

**Permissions details**

This policy includes the following permissions:
+ `bedrock-mantle` (Amazon Bedrock Mantle) – Allows principals full access to all actions in the Amazon Bedrock Mantle service.

## AWS managed policy: AmazonBedrockMantleReadOnly
<a name="security-iam-awsmanpol-AmazonBedrockMantleReadOnly"></a>

You can attach the [AmazonBedrockMantleReadOnly](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockMantleReadOnly.html) policy to your IAM identities to grant read-only permissions to view Amazon Bedrock Mantle resources and call with bearer token.

**Permissions details**

This policy includes the following permissions:
+ `bedrock-mantle` (Amazon Bedrock Mantle) – Allows principals to get and list Amazon Bedrock Mantle project resources, and call with bearer token for authentication.

## AWS managed policy: AmazonBedrockMantleInferenceAccess
<a name="security-iam-awsmanpol-AmazonBedrockMantleInferenceAccess"></a>

You can attach the [AmazonBedrockMantleInferenceAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonBedrockMantleInferenceAccess.html) policy to your IAM identities to grant permissions to run inference on Amazon Bedrock Mantle models.

**Permissions details**

This policy includes the following permissions:
+ `bedrock-mantle` (Amazon Bedrock Mantle) – Allows principals to get and list Amazon Bedrock Mantle project resources, create inference requests, and call with bearer token for authentication.

## Amazon Bedrock updates to AWS managed policies
<a name="security-iam-awsmanpol-updates"></a>

View details about updates to AWS managed policies for Amazon Bedrock since this service began tracking these changes. For automatic alerts about changes to this page, subscribe to the RSS feed on the [Document history for the Amazon Bedrock User Guide](doc-history.md).


| Change | Description | Date | 
| --- | --- | --- | 
|  [AmazonBedrockMantleFullAccess](#security-iam-awsmanpol-AmazonBedrockMantleFullAccess) – New policy  |  Amazon Bedrock added a new policy to grant full access to all Amazon Bedrock Mantle operations.  | December 3, 2025 | 
|  [AmazonBedrockMantleReadOnly](#security-iam-awsmanpol-AmazonBedrockMantleReadOnly) – New policy  |  Amazon Bedrock added a new policy to grant read-only access to Amazon Bedrock Mantle resources.  | December 3, 2025 | 
|  [AmazonBedrockMantleInferenceAccess](#security-iam-awsmanpol-AmazonBedrockMantleInferenceAccess) – New policy  |  Amazon Bedrock added a new policy to grant inference access to Amazon Bedrock Mantle models.  | December 3, 2025 | 
|  [AmazonBedrockFullAccess](#security-iam-awsmanpol-AmazonBedrockFullAccess) – Updated policy  |  Amazon Bedrock updated the AmazonBedrockFullAccess managed policy to enable access to all serverless foundation models by default.  | July 14th, 2025 | 
|  [AmazonBedrockMarketplaceAccess](#security-iam-awsmanpol-AmazonBedrockLimitedAccess) – New policy  |  Amazon Bedrock added a new policy to grant customers permissions to access Amazon Bedrock Marketplace foundation models through a SageMaker AI endpoint.  | June 13, 2025 | 
|  [AmazonBedrockLimitedAccess](#security-iam-awsmanpol-AmazonBedrockLimitedAccess) – New policy  |  Amazon Bedrock added a new policy to grant customers basic permissions to access core actions in Amazon Bedrock.  | June 13, 2025 | 
|  [AmazonBedrockFullAccess](#security-iam-awsmanpol-AmazonBedrockFullAccess) – Updated policy  |  Amazon Bedrock updated the AmazonBedrockFullAccess managed policy to grant customers the necessary permissions to create, read, update, and delete Amazon Bedrock Marketplace resources. This includes permissions to manage the underlying Amazon SageMaker AI resources, as they serve as the foundation for the Amazon Bedrock Marketplace functionality.  | December 4th, 2024 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy  |  Amazon Bedrock updated the AmazonBedrockReadOnly managed policy to grant customers the necessary permissions to read Amazon Bedrock Marketplace resources. This includes permissions to manage the underlying Amazon SageMaker AI resources, as they serve as the foundation for the Amazon Bedrock Marketplace functionality.  | December 4th, 2024 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy  |  Amazon Bedrock updated the AmazonBedrockReadOnly policy to include read-only permissions for custom model import.  | October 18, 2024 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy  |  Amazon Bedrock added inference profile read-only permissions.  | August 27, 2024 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy  |  Amazon Bedrock updated the AmazonBedrockReadOnly policy to include read-only permissions for Amazon Bedrock Guardrails, Amazon Bedrock Model evaluation, and Amazon Bedrock Batch inference.  | August 21, 2024 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy  |  Amazon Bedrock added batch inference (model invocation job) read-only permissions.  | August 21, 2024 | 
|   [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – Updated policy   |  Amazon Bedrock updated the AmazonBedrockReadOnly policy to include read-only permissions for Amazon Bedrock Custom Model Import.  | September 3, 2024 | 
|  [AmazonBedrockFullAccess](#security-iam-awsmanpol-AmazonBedrockFullAccess) – New policy  |  Amazon Bedrock added a new policy to give users permissions to create, read, update, and delete resources.  | December 12, 2023 | 
|  [AmazonBedrockReadOnly](#security-iam-awsmanpol-AmazonBedrockReadOnly) – New policy  |  Amazon Bedrock added a new policy to give users read-only permissions for all actions.  | December 12, 2023 | 
|  Amazon Bedrock started tracking changes  |  Amazon Bedrock started tracking changes for its AWS managed policies.  | December 12, 2023 | 

# Service roles
<a name="security-iam-sr"></a>

Amazon Bedrock uses [IAM service roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role) for some features to let Amazon Bedrock carry out tasks on your behalf.

The console automatically creates service roles for supported features.

You can also create a custom service role and customize the attached permissions to your specific use-case. If you use the console, you can select this role instead of letting Amazon Bedrock create one for you.

To set up the custom service role, you carry out the following general steps.

1. Create the role by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).

1. Attach a **trust policy**.

1. Attach the relevant **identity-based permissions**.

**Important**  
When setting the `iam:PassRole` permission, make sure that a user can't pass a role where the role has more permissions than you want the user to have. For example, Alice might not be allowed to perform `bedrock:InvokeModel` on a custom model. If Alice can pass a role to Amazon Bedrock to create an evaluation of that custom model, the service could invoke that model on behalf of Alice while running the job.

Refer to the following links for more information about IAM concepts that are relevant to setting service role permissions.
+ [AWS service role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role)
+ [Identity-based policies and resource-based policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html)
+ [Using resource-based policies for Lambda](https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html)
+ [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)
+ [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)

Select a topic to learn more about service roles for a specific feature.

**Topics**
+ [Create a custom service role for batch inference](batch-iam-sr.md)
+ [Create a service role for model customization](model-customization-iam-role.md)
+ [Create a service role for importing pre-trained models](model-import-iam-role.md)
+ [Create a service role for Amazon Bedrock Agents](agents-permissions.md)
+ [Create a service role for Amazon Bedrock Knowledge Bases](kb-permissions.md)
+ [Create a service role for Amazon Bedrock Flows in Amazon Bedrock](flows-permissions.md)
+ [Service role requirements for model evaluation jobs](model-evaluation-security-service-roles.md)

# Create a custom service role for batch inference
<a name="batch-iam-sr"></a>

To use a custom service role for batch inference instead of the one Amazon Bedrock automatically creates for you in the AWS Management Console, create an IAM role and attach the following permissions by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).

**Topics**
+ [Trust relationship](#batch-iam-sr-trust)
+ [Identity-based permissions for the batch inference service role.](#batch-iam-sr-identity)

## Trust relationship
<a name="batch-iam-sr-trust"></a>

The following trust policy allows Amazon Bedrock to assume this role and submit and manage batch inference jobs. Replace the *values* as necessary. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.

**Note**  
As a best practice for security purposes, replace the *\$1* with specific batch inference job IDs after you have created them.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnEquals": {
                    "aws:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:model-invocation-job/*"
                }
            }
        }
    ]
}
```

------

## Identity-based permissions for the batch inference service role.
<a name="batch-iam-sr-identity"></a>

The following topics describe and provide examples of permissions policies that you might need to attach to your custom batch inference service role, depending on your use case.

**Topics**
+ [(Required) Permissions to access input and output data in Amazon S3](#batch-iam-sr-s3)
+ [(Optional) Permissions to run batch inference with inference profiles](#batch-iam-sr-ip)

### (Required) Permissions to access input and output data in Amazon S3
<a name="batch-iam-sr-s3"></a>

To allow a service role to access the Amazon S3 bucket containing your input data and the bucket to which to write your output data, attach the following policy to the service role. Replace *values* as necessary.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
         "Sid": "S3Access",
         "Effect": "Allow",
         "Action": [
            "s3:GetObject",
            "s3:PutObject",
            "s3:ListBucket"
         ],
         "Resource": [
            "arn:aws:s3:::${InputBucket}",
            "arn:aws:s3:::${InputBucket}/*",
            "arn:aws:s3:::${OutputBucket}",
            "arn:aws:s3:::${OutputBucket}/*"
         ],
         "Condition": {
            "StringEquals": {
                "aws:ResourceAccount": [
                    "123456789012"
                ]
            }
         }
        }
    ]
}
```

------

### (Optional) Permissions to run batch inference with inference profiles
<a name="batch-iam-sr-ip"></a>

To run batch inference with an [inference profile](inference-profiles.md), a service role must have permissions to invoke the inference profile in an AWS Region, in addition to the model in each Region in the inference profile.

For permissions to invoke with a cross-Region (system-defined) inference profile, use the following policy as a template for the permissions policy to attach to your service role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CrossRegionInference",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:inference-profile/${InferenceProfileId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}"
            ]
        }
    ]
}
```

------

For permissions to invoke with an application inference profile, use the following policy as a template for the permissions policy to attach to your service role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ApplicationInferenceProfile",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/${InferenceProfileId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}"
            ]
        }
    ]
}
```

------

# Create a service role for model customization
<a name="model-customization-iam-role"></a>

To use a custom role for model customization instead of the one Amazon Bedrock automatically creates, create an IAM role and attach the following permissions by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).
+ Trust relationship
+ Permissions to access your training and validation data in S3 and to write your output data to S3
+ (Optional) If you encrypt any of the following resources with a KMS key, permissions to decrypt the key (see [Encryption of custom models](encryption-custom-job.md))
  + A model customization job or the resulting custom model
  + The training, validation, or output data for the model customization job

**Topics**
+ [Trust relationship](#model-customization-iam-role-trust)
+ [Permissions to access training and validation files and to write output files in S3](#model-customization-iam-role-s3)
+ [(Optional) Permissions to create a Distillation job with a cross-region inference profiles](#customization-iam-sr-ip)

## Trust relationship
<a name="model-customization-iam-role-trust"></a>

The following policy allows Amazon Bedrock to assume this role and carry out the model customization job. The following shows an example policy you can use.

You can optionally restrict the scope of the permission for [cross-service confused deputy prevention](cross-service-confused-deputy-prevention.md) by using one or more global condition context keys with the `Condition` field. For more information, see [AWS global condition context keys.](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)
+ Set the `aws:SourceAccount` value to your account ID.
+ (Optional) Use the `ArnEquals` or `ArnLike` condition to restrict the scope to specific model customization jobs in your account ID.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnEquals": {
                    "aws:SourceArn": "arn:aws:bedrock:us-east-1:111122223333:model-customization-job/*"
                }
            }
        }
    ]
}
```

------

## Permissions to access training and validation files and to write output files in S3
<a name="model-customization-iam-role-s3"></a>

Attach the following policy to allow the role to access your training and validation data and the bucket to which to write your output data. Replace the values in the `Resource` list with your actual bucket names.

To restrict access to a specific folder in a bucket, add an `s3:prefix` condition key with your folder path. You can follow the **User policy** example in [Example 2: Getting a list of objects in a bucket with a specific prefix](https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html#condition-key-bucket-ops-2) 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::training-bucket",
                "arn:aws:s3:::training-bucket/*",
                "arn:aws:s3:::validation-bucket",
                "arn:aws:s3:::validation-bucket/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::output-bucket",
                "arn:aws:s3:::output-bucket/*"
            ]
        }
    ]
}
```

------

## (Optional) Permissions to create a Distillation job with a cross-region inference profiles
<a name="customization-iam-sr-ip"></a>

To use a cross-region inference profile for a teacher model in a distillation job, the service role must have permissions to invoke the inference profile in an AWS Region, in addition to the model in each Region in the inference profile.

For permissions to invoke with a cross-Region (system-defined) inference profile, use the following policy as a template for the permissions policy to attach to your service role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CrossRegionInference",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:inference-profile/${InferenceProfileId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}",
                "arn:aws:bedrock:us-east-1::foundation-model/${ModelId}"
            ]
        }
    ]
}
```

------

# Create a service role for importing pre-trained models
<a name="model-import-iam-role"></a>

To use a custom role for model import create an IAM service role and attach the following permissions. For information on how to create a service role in IAM, see [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).

These permissions apply to both methods of importing models into Amazon Bedrock:
+ **Custom model import jobs** — For importing customized open-source foundation models (such as Mistral AI or Llama models). For more information, see [Use Custom model import to import a customized open-source model into Amazon Bedrock](model-customization-import-model.md).
+ **Create custom model** — For importing Amazon Nova models that you fine-tuned in SageMaker AI. For more information, see [Import a SageMaker AI-trained Amazon Nova model](import-with-create-custom-model.md).

**Topics**
+ [Trust relationship](#model-import-iam-role-trust)
+ [Permissions to access model files in Amazon S3](#model-import-iam-role-s3)

## Trust relationship
<a name="model-import-iam-role-trust"></a>

The following policy allows Amazon Bedrock to assume this role and carry out model import operations. The following shows an example policy you can use.

You can optionally restrict the scope of the permission for [cross-service confused deputy prevention](cross-service-confused-deputy-prevention.md) by using one or more global condition context keys with the `Condition` field. For more information, see [AWS global condition context keys.](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)
+ Set the `aws:SourceAccount` value to your account ID.
+ (Optional) Use the `ArnEquals` or `ArnLike` condition to restrict the scope to specific operations in your account. The following example restricts access to custom model import jobs.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "1",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnEquals": {
                    "aws:SourceArn": "arn:aws:bedrock:us-east-1:111122223333:model-import-job/*"
                }
            }
        }
    ]
}
```

------

## Permissions to access model files in Amazon S3
<a name="model-import-iam-role-s3"></a>

Attach the following policy to allow the role to access model files in Amazon S3 bucket. Replace the values in the `Resource` list with your actual bucket names.

For custom model import jobs, this is your own Amazon S3 bucket containing the customized open-source model files. For creating custom models from SageMaker AI-trained Amazon Nova models, this is the Amazon-managed Amazon S3 bucket where SageMaker AI stores the trained model artifacts. SageMaker AI creates this bucket when you run your first SageMaker AI training job. 

To restrict access to a specific folder in a bucket, add an `s3:prefix` condition key with your folder path. You can follow the **User policy** example in [Example 2: Getting a list of objects in a bucket with a specific prefix](https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html#condition-key-bucket-ops-2) 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "1",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::bucket",
                "arn:aws:s3:::bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        }
    ]
}
```

------

# Create a service role for Amazon Bedrock Agents
<a name="agents-permissions"></a>

To use a custom service role for agents instead of the one Amazon Bedrock automatically creates, create an IAM role and attach the following permissions by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).
+ Trust policy
+ A policy containing the following identity-based permissions:
  + Access to the Amazon Bedrock base models.
  + Access to the Amazon S3 objects containing the OpenAPI schemas for the action groups in your agents.
  + Permissions for Amazon Bedrock to query knowledge bases that you want to attach to your agents.
  + If any of the following situations pertain to your use case, add the statement to the policy or add a policy with the statement to the service role:
    + (Optional) If you enable multi-agent collaboration, permissions to get the aliases and invoke agent collaborators.
    + (Optional) If you associate a Provisioned Throughput with your agent alias, permissions to perform model invocation using that Provisioned Throughput.
    + (Optional) If you associate a guardrail with your agent, permissions to apply that guardrail. If the guardrail is encrypted with a KMS key, the service role will also need [permissions to decrypt the key](guardrails-permissions-kms.md)
    + (Optional) If you encrypt your agent with a KMS key, [permissions to decrypt the key](encryption-agents.md).

Whether you use a custom role or not, you also need to attach a **resource-based policy** to the Lambda functions for the action groups in your agents to provide permissions for the service role to access the functions. For more information, see [Resource-based policy to allow Amazon Bedrock to invoke an action group Lambda function](#agents-permissions-lambda).

**Topics**
+ [Trust relationship](#agents-permissions-trust)
+ [Identity-based permissions for the Agents service role](#agents-permissions-identity)
+ [(Optional) Identity-based policy to allow Amazon Bedrock to use Provisioned Throughput with your agent alias](#agents-permissions-pt)
+ [(Optional) Identity-based policy to allow Amazon Bedrock to associate and invoke agent collaborators](#agents-permissions-mac)
+ [(Optional) Identity-based policy to allow Amazon Bedrock to use guardrails with your Agent](#agents-permissions-gr)
+ [(Optional) Identity-based policy to allow Amazon Bedrock to access files from S3 to use with code interpretation](#agents-permissions-files-ci)
+ [Resource-based policy to allow Amazon Bedrock to invoke an action group Lambda function](#agents-permissions-lambda)

## Trust relationship
<a name="agents-permissions-trust"></a>

The following trust policy allows Amazon Bedrock to assume this role and create and manage agents. Replace the *\$1\$1values\$1* as necessary. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.

**Note**  
As a best practice for security purposes, replace the *\$1* with specific agent IDs after you have created them.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "AWS:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:agent/*"
                }
            }
        }
    ]
}
```

------

## Identity-based permissions for the Agents service role
<a name="agents-permissions-identity"></a>

Attach the following policy to provide permissions for the service role, replacing *\$1\$1values\$1* as necessary. The policy contains the following statements. Omit a statement if it isn't applicable to your use-case. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.

**Note**  
If you encrypt your agent with a customer-managed KMS key, refer to [Encryption of agent resources for agents created before January 22, 2025](encryption-agents.md) for further permissions you need to add.
+ Permissions to use Amazon Bedrock foundation models to run model inference on prompts used in your agent's orchestration.
+ Permissions to access your agent's action group API schemas in Amazon S3. Omit this statement if your agent has no action groups.
+ Permissions to access knowledge bases associated with your agent. Omit this statement if your agent has no associated knowledge bases.
+ Permissions to access a third-party (Pinecone or Redis Enterprise Cloud) knowledge base associated with your agent. Omit this statement if your knowledge base is first-party (Amazon OpenSearch Serverless or Amazon Aurora) or if your agent has no associated knowledge bases.
+ Permissions to access a prompt from Prompt management. Omit this statement if you don't plan to test a prompt from prompt management with your agent in the Amazon Bedrock console.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AgentModelInvocationPermissions",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2",
                "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2:1",
                "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-instant-v1"
            ]
        },
        {
            "Sid": "AgentActionGroupS3",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/SchemaJson"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        },
        {
            "Sid": "AgentKnowledgeBaseQuery",
            "Effect": "Allow",
            "Action": [
                "bedrock:Retrieve",
                "bedrock:RetrieveAndGenerate"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/knowledge-base-id"
            ]
        },
        {
            "Sid": "Agent3PKnowledgeBase",
            "Effect": "Allow",
            "Action": [
                "bedrock:AssociateThirdPartyKnowledgeBase"
            ],
            "Resource": "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/knowledge-base-id",
            "Condition": {
                "StringEquals": {
                    "bedrock:ThirdPartyKnowledgeBaseCredentialsSecretArn": "arn:aws:kms:us-east-1:123456789012:key/KeyId"
                }
            }
        },
        {
            "Sid": "AgentPromptManagementConsole",
            "Effect": "Allow",
            "Action": [
                "bedrock:GetPrompt"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:prompt/prompt-id"
            ]
        }
    ]
}
```

------

## (Optional) Identity-based policy to allow Amazon Bedrock to use Provisioned Throughput with your agent alias
<a name="agents-permissions-pt"></a>

If you associate a [Provisioned Throughput](prov-throughput.md) with an alias of your agent, attach the following identity-based policy to the service role or add the statement to the policy in [Identity-based permissions for the Agents service role](#agents-permissions-identity).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
      {        
        "Sid": "UseProvisionedThroughput",
        "Effect": "Allow",
        "Action": [
            "bedrock:InvokeModel", 
            "bedrock:GetProvisionedModelThroughput"
        ],
        "Resource": [
            "arn:aws:bedrock:us-east-1:123456789012:provisioned-model/${provisioned-model-id}"
        ]
      }
    ]
}
```

------

## (Optional) Identity-based policy to allow Amazon Bedrock to associate and invoke agent collaborators
<a name="agents-permissions-mac"></a>

If you enable [multi-agent collaboration](agents-multi-agent-collaboration.md), attach the following identity-based policy to the service role or add the statement to the policy in [Identity-based permissions for the Agents service role](#agents-permissions-identity).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AmazonBedrockAgentMultiAgentsPolicyProd",
            "Effect": "Allow",
            "Action": [
                "bedrock:GetAgentAlias",
                "bedrock:InvokeAgent"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:agent-alias/${agent-id}/${agent-alias-id}"
            ]
        }
    ]
}
```

------

## (Optional) Identity-based policy to allow Amazon Bedrock to use guardrails with your Agent
<a name="agents-permissions-gr"></a>

If you associate a [guardrail](guardrails.md) with your agent, attach the following identity-based policy to the service role or add the statement to the policy in [Identity-based permissions for the Agents service role](#agents-permissions-identity).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ApplyGuardrail",
            "Effect": "Allow",
            "Action": "bedrock:ApplyGuardrail",
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/${guardrail-id}"
            ]
        }
    ]
}
```

------

## (Optional) Identity-based policy to allow Amazon Bedrock to access files from S3 to use with code interpretation
<a name="agents-permissions-files-ci"></a>

If you enable [Enable code interpretation in Amazon Bedrock](agents-enable-code-interpretation.md), attach the following identity-based policy to the service role or add the statement to the policy in [Identity-based permissions for the Agents service role](https://docs.aws.amazon.com//bedrock/latest/userguide/agents-permissions.html#agents-permissions-identity).

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
      {       
        "Sid": "AmazonBedrockAgentFileAccess", 
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:GetObjectVersion",
            "s3:GetObjectVersionAttributes",
            "s3:GetObjectAttributes"
        ],
        "Resource": [
            "arn:aws:s3:::[[customerProvidedS3BucketWithKey]]"
        ]
      }
    ]
}
```

------

## Resource-based policy to allow Amazon Bedrock to invoke an action group Lambda function
<a name="agents-permissions-lambda"></a>

Follow the steps at [Using resource-based policies for Lambda](https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html) and attach the following resource-based policy to a Lambda function to allow Amazon Bedrock to access the Lambda function for your agent's action groups, replacing the *\$1\$1values\$1* as necessary. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AccessLambdaFunction",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "lambda:InvokeFunction",
            "Resource": "arn:aws:lambda:us-east-1:123456789012:function:function-name",
            "Condition": {
                "StringEquals": {
                    "AWS:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "AWS:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:agent/${agent-id}"
                }
            }
        }
    ]
}
```

------

# Create a service role for Amazon Bedrock Knowledge Bases
<a name="kb-permissions"></a>

To use a custom role for a knowledge base instead of the one Amazon Bedrock automatically creates, create an IAM role and attach the following permissions by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html). Include only the necessary permissions for your own security.

**Note**  
A policy cannot be shared between multiple roles when the service role is used.
+ Trust relationship
+ Access to the Amazon Bedrock base models
+ Access to the data source for where you store your data
+ (If you create a vector database in Amazon OpenSearch Service) Access to your OpenSearch Service collection
+ (If you create a vector database in Amazon Aurora) Access to your Aurora cluster
+ (If you create a vector database in Pinecone or Redis Enterprise Cloud) Permissions for AWS Secrets Manager to authenticate your Pinecone or Redis Enterprise Cloud account
+ (Optional) If you encrypt any of the following resources with a KMS key, permissions to decrypt the key (see [Encryption of knowledge base resources](encryption-kb.md)).
  + Your knowledge base
  + Data sources for your knowledge base
  + Your vector database in Amazon OpenSearch Service
  + The secret for your third-party vector database in AWS Secrets Manager
  + A data ingestion job

**Topics**
+ [Trust relationship](#kb-permissions-trust)
+ [Permissions to access Amazon Bedrock models](#kb-permissions-access-models)
+ [Permissions to access your data sources](#kb-permissions-access-ds)
+ [Permissions to decrypt your AWS KMS key for encrypted data sources in Amazon S3](#kb-permissions-kms-datasource)
+ [Permissions to chat with your document](#kb-permissions-chatdoc)
+ [Permissions for multimodal content](#kb-permissions-multimodal)
+ [Permissions to access your Amazon Kendra GenAI index](#kb-permissions-kendra)
+ [Permissions to access your vector database in Amazon OpenSearch Serverless](#kb-permissions-oss)
+ [Permissions to access your vector database in OpenSearch Managed Clusters](#kb-permissions-osm)
+ [Permissions to access your Amazon Aurora database cluster](#kb-permissions-rds)
+ [Permissions to access your vector database in Amazon Neptune Analytics](#kb-permissions-neptune)
+ [Permissions to access your vector store in Amazon S3 Vectors](#kb-permissions-s3vectors)
+ [Permissions to access a vector database configured with an AWS Secrets Manager secret](#kb-permissions-secret)
+ [Permissions for AWS to manage a AWS KMS key for transient data storage during data ingestion](#kb-permissions-kms-ingestion)
+ [Permissions for AWS to manage a data sources from another user's AWS account.](#kb-permissions-otherds)

## Trust relationship
<a name="kb-permissions-trust"></a>

The following policy allows Amazon Bedrock to assume this role and create and manage knowledge bases. The following shows an example policy you can use. You can restrict the scope of the permission by using one or more global condition context keys. For more information, see [AWS global condition context keys.](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) Set the `aws:SourceAccount` value to your account ID. Use the `ArnEquals` or `ArnLike` condition to restrict the scope to specific knowledge bases.

**Note**  
As a best practice for security purposes, replace the *\$1* with specific knowledge base IDs after you have created them.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "AWS:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/*"
                }
            }
        }
    ]
}
```

------

## Permissions to access Amazon Bedrock models
<a name="kb-permissions-access-models"></a>

Attach the following policy to provide permissions for the role to use Amazon Bedrock models to embed your source data.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:ListFoundationModels",
                "bedrock:ListCustomModels"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-embed-text-v1",
                "arn:aws:bedrock:us-east-1::foundation-model/cohere.embed-english-v3",
                "arn:aws:bedrock:us-east-1::foundation-model/cohere.embed-multilingual-v3"
            ]
        }
    ]
}
```

------

## Permissions to access your data sources
<a name="kb-permissions-access-ds"></a>

Select from the following data sources to attach the necessary permissions for the role.

**Topics**
+ [Permissions to access your Amazon S3 data source](#kb-permissions-access-s3)
+ [Permissions to access your Confluence data source](#kb-permissions-access-confluence)
+ [Permissions to access your Microsoft SharePoint data source](#kb-permissions-access-sharepoint)
+ [Permissions to access your Salesforce data source](#kb-permissions-access-salesforce)

### Permissions to access your Amazon S3 data source
<a name="kb-permissions-access-s3"></a>

If your data source is Amazon S3, attach the following policy to provide permissions for the role to access the S3 bucket that you will connect to as your data source.

If you encrypted the data source with a AWS KMS key, attach permissions to decrypt the key to the role by following the steps at [Permissions to decrypt your AWS KMS key for your data sources in Amazon S3](encryption-kb.md#encryption-kb-ds).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "S3ListBucketStatement",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        },
        {
            "Sid": "S3GetObjectStatement",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        }
    ]
}
```

------

### Permissions to access your Confluence data source
<a name="kb-permissions-access-confluence"></a>

**Note**  
Confluence data source connector is in preview release and is subject to change.

Attach the following policy to provide permissions for the role to access Confluence.

**Note**  
`secretsmanager:PutSecretValue` is only necessary if you use OAuth 2.0 authentication with a refresh token.  
Confluence OAuth2.0 **access** token has a default expiry time of 60 minutes. If this token expires while your data source is syncing (sync job), Amazon Bedrock will use the provided **refresh** token to regenerate this token. This regeneration refreshes both the access and refresh tokens. To keep the tokens updated from the current sync job to the next sync job, Amazon Bedrock requires write/put permissions for your secret credentials.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue",
                "secretsmanager:PutSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretId"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt"
            ],
            "Resource": [
                "arn:aws:kms:us-east-1:123456789012:key/KeyId"
            ],
            "Condition": {
                "StringLike": {
                    "kms:ViaService": [
                        "secretsmanager.us-east-1.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

### Permissions to access your Microsoft SharePoint data source
<a name="kb-permissions-access-sharepoint"></a>

**Note**  
SharePoint data source connector is in preview release and is subject to change.

Attach the following policy to provide permissions for the role to access SharePoint.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretId"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt"
            ],
            "Resource": [
                "arn:aws:kms:us-east-1:123456789012:key/KeyId"
            ],
            "Condition": {
                "StringLike": {
                    "kms:ViaService": [
                        "secretsmanager.us-east-1.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

### Permissions to access your Salesforce data source
<a name="kb-permissions-access-salesforce"></a>

**Note**  
Salesforce data source connector is in preview release and is subject to change.

Attach the following policy to provide permissions for the role to access Salesforce.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretId"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt"
            ],
            "Resource": [
                "arn:aws:kms:us-east-1:123456789012:key/KeyId"
            ],
            "Condition": {
                "StringLike": {
                    "kms:ViaService": [
                        "secretsmanager.us-east-1.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

## Permissions to decrypt your AWS KMS key for encrypted data sources in Amazon S3
<a name="kb-permissions-kms-datasource"></a>

If you encrypted your data sources in Amazon S3 with a AWS KMS key, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow Amazon Bedrock to decrypt your key. Replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the key belongs. Replace *\$1\$1KeyId\$1* with the ID of your AWS KMS key.

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [{
        "Effect": "Allow",
        "Action": [
            "kms:Decrypt"
        ],
        "Resource": [
            "arn:aws:kms:${Region}:${AccountId}:key/${KeyId}"
        ],
        "Condition": {
            "StringEquals": {
                "kms:ViaService": [
                    "s3.${Region}.amazonaws.com"
                ]
            }
        }
    }]
}
```

## Permissions to chat with your document
<a name="kb-permissions-chatdoc"></a>

Attach the following policy to provide permissions for the role to use Amazon Bedrock models to chat with your document:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
			"Effect": "Allow",
			"Action": [
				"bedrock:RetrieveAndGenerate"
			],
			"Resource": "*"
		}
    ]
}
```

------

If you only want to grant a user access to chat with your document (and not to `RetrieveAndGenerate` on all Knowledge Bases), use the following policy:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
			"Effect": "Allow",
			"Action": [
				"bedrock:RetrieveAndGenerate"
			],
			"Resource": "*"
		},
        {
			"Effect": "Deny",
			"Action": [
				"bedrock:Retrieve"
			],
			"Resource": "*"
		}
    ]
}
```

------

If you want both chat with your document and use `RetrieveAndGenerate` on a specific Knowledge Base, provide a *\$1\$1KnowledgeBaseArn\$1*, and use the following policy:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:RetrieveAndGenerate"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:Retrieve"
            ],
            "Resource": "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/$KnowledgeBaseId"
        }
    ]
}
```

------

## Permissions for multimodal content
<a name="kb-permissions-multimodal"></a>

When working with multimodal content (images, audio, video), additional permissions are required depending on your processing approach.

### Nova Multimodal Embeddings permissions
<a name="kb-permissions-multimodal-mme"></a>

When using Nova Multimodal Embeddings, attach the following policy to provide permissions for asynchronous model invocation:

```
{
    "Sid": "BedrockInvokeModelStatement",
    "Effect": "Allow",
    "Action": ["bedrock:InvokeModel"],
    "Resource": [
        "arn:aws:bedrock:us-east-1::foundation-model/amazon.nova-*-multimodal-embeddings-*",
        "arn:aws:bedrock:us-east-1::async-invoke/*"
    ],
    "Condition": {
        "StringEquals": {
            "aws:ResourceAccount": ""
        }
    }
},
{
    "Sid": "BedrockGetAsyncInvokeStatement",
    "Effect": "Allow",
    "Action": ["bedrock:GetAsyncInvoke"],
    "Resource": ["arn:aws:bedrock:us-east-1::async-invoke/*"],
    "Condition": {
        "StringEquals": {
            "aws:ResourceAccount": ""
        }
    }
}
```

### Bedrock Data Automation (BDA) permissions
<a name="kb-permissions-multimodal-bda"></a>

When using BDA to process multimodal content, attach the following policy:

```
{
    "Sid": "BDAInvokeStatement",
    "Effect": "Allow",
    "Action": ["bedrock:InvokeDataAutomationAsync"],
    "Resource": [
        "arn:aws:bedrock:us-east-1:aws:data-automation-project/public-rag-default",
        "arn:aws:bedrock:us-east-1::data-automation-profile/*"
    ]
},
{
    "Sid": "BDAGetStatement",
    "Effect": "Allow",
    "Action": ["bedrock:GetDataAutomationStatus"],
    "Resource": "arn:aws:bedrock:us-east-1::data-automation-invocation/*"
}
```

If you use customer-managed AWS KMS keys with BDA, also attach the following policy. Replace *account-id*, *region*, and *key-id* with your specific values:

```
{
    "Sid": "KmsPermissionStatementForBDA",
    "Effect": "Allow",
    "Action": [
        "kms:GenerateDataKey",
        "kms:Decrypt",
        "kms:DescribeKey",
        "kms:CreateGrant"
    ],
    "Resource": ["arn:aws:kms:region:account-id:key/key-id"],
    "Condition": {
        "StringEquals": {
            "aws:ResourceAccount": "account-id",
            "kms:ViaService": "bedrock.region.amazonaws.com"
        }
    }
}
```

## Permissions to access your Amazon Kendra GenAI index
<a name="kb-permissions-kendra"></a>

If you created an Amazon Kendra GenAI index for your knowledge base, then attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the index. In the policy, replace *\$1\$1Partition\$1*, *\$1\$1Region\$1*, *\$1\$1AccountId\$1*, and *\$1\$1IndexId\$1* with the values for your index. You can allow access to multiple indexes by adding them to the `Resource` list. To allow access to every index in your AWS account, replace *\$1\$1IndexId\$1* with a wildcard (\$1).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kendra:Retrieve",
                "kendra:DescribeIndex"
            ],
            "Resource": "arn:aws:kendra:us-east-1:123456789012:index/${IndexId}" 
        }
    ]
}
```

------

## Permissions to access your vector database in Amazon OpenSearch Serverless
<a name="kb-permissions-oss"></a>

If you created a vector database in OpenSearch Serverless for your knowledge base, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the collection. Replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the database belongs. Input the ID of your Amazon OpenSearch Service collection in *\$1\$1CollectionId\$1*. You can allow access to multiple collections by adding them to the `Resource` list.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "aoss:APIAccessAll"
            ],
            "Resource": [
                "arn:aws:aoss:us-east-1:123456789012:collection/${CollectionId}"
            ]
        }
    ]
}
```

------

## Permissions to access your vector database in OpenSearch Managed Clusters
<a name="kb-permissions-osm"></a>

If you created a vector database in OpenSearch Managed Cluster for your knowledge base, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the domain. Replace *<region>* and *<accountId>* with the Region and account ID to which the database belongs. You can allow access to multiple domains by adding them to the `Resource` list. For more information about configuring permissions, see [Prerequisites and permissions required for using OpenSearch Managed Clusters with Amazon Bedrock Knowledge BasesOverview of permissions configuration](kb-osm-permissions-prereq.md).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",       
            "Action": [
                "es:ESHttpGet", 
                "es:ESHttpPost", 
                "es:ESHttpPut", 
                "es:ESHttpDelete" 
            ],
            "Resource": [
                "arn:aws:es:us-east-1:123456789012:domain/domainName/indexName"
            ]       
        }, 
        {
            "Effect": "Allow",
            "Action": [
                "es:DescribeDomain" 
            ],
            "Resource": [
                "arn:aws:es:us-east-1:123456789012:domain/domainName"
            ]       
        }
    ]
}
```

------

## Permissions to access your Amazon Aurora database cluster
<a name="kb-permissions-rds"></a>

**Note**  
The Amazon Aurora cluster must reside in the same AWS account as the one where the knowledge base is created for Amazon Bedrock.

If you created a database (DB) cluster in Amazon Aurora for your knowledge base, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the DB cluster and to provide read and write permissions on it. Replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the DB cluster belongs. Input the ID of your Amazon Aurora database cluster in *\$1\$1DbClusterId\$1*. You can allow access to multiple DB clusters by adding them to the `Resource` list.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RdsDescribeStatementID",
            "Effect": "Allow",
            "Action": [
                "rds:DescribeDBClusters"
            ],
            "Resource": [
                "arn:aws:rds:us-east-1:123456789012:cluster:${DbClusterId}"
            ]
        },
        {
            "Sid": "DataAPIStatementID",
            "Effect": "Allow",
            "Action": [
                "rds-data:BatchExecuteStatement",
                "rds-data:ExecuteStatement"
            ],
            "Resource": [
                "arn:aws:rds:us-east-1:123456789012:cluster:${DbClusterId}"
            ]
        }
    ]
}
```

------

## Permissions to access your vector database in Amazon Neptune Analytics
<a name="kb-permissions-neptune"></a>

If you created an Amazon Neptune Analytics graph for your knowledge base, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the graph. In the policy, replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the database belongs. Replace *\$1\$1GraphId\$1* with the values for your graph database.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "NeptuneAnalyticsAccess",
            "Effect": "Allow",
            "Action": [
                "neptune-graph:GetGraph",
                "neptune-graph:ReadDataViaQuery",
                "neptune-graph:WriteDataViaQuery",
                "neptune-graph:DeleteDataViaQuery"
            ],
            "Resource": [
                "arn:aws:neptune-graph:us-east-1:123456789012:graph/${GraphId}"
            ]
        }
    ]
}
```

------

## Permissions to access your vector store in Amazon S3 Vectors
<a name="kb-permissions-s3vectors"></a>

If you choose to use Amazon S3 Vectors for your knowledge base, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow access to the vector index.

In the policy, replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the vector index belongs. Replace *\$1\$1BucketName\$1* with the name of your S3 vector bucket and *\$1\$1IndexName\$1* with the name of your vector index. For more information about Amazon S3 Vectors, see [Setting up to use Amazon S3 Vectors](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vectors-setting-up.html).

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "S3VectorBucketReadAndWritePermission",
            "Effect": "Allow",
            "Action": [
                "s3vectors:PutVectors",
                "s3vectors:GetVectors",
                "s3vectors:DeleteVectors",
                "s3vectors:QueryVectors",
                "s3vectors:GetIndex"
            ],
            "Resource": "arn:aws:s3vectors:us-east-1:123456789012:bucket/${BucketName}/index/${IndexName}"
        }
    ]
}
```

------

## Permissions to access a vector database configured with an AWS Secrets Manager secret
<a name="kb-permissions-secret"></a>

If your vector database is configured with an AWS Secrets Manager secret, attach the following policy to your Amazon Bedrock Knowledge Bases service role to allow AWS Secrets Manager to authenticate your account to access the database. Replace *\$1\$1Region\$1* and *\$1\$1AccountId\$1* with the Region and account ID to which the database belongs. Replace *\$1\$1SecretId\$1* with the ID of your secret.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:us-east-1:123456789012:secret:${SecretId}"
            ]
        }
    ]
}
```

------

If you encrypted your secret with a AWS KMS key, attach permissions to decrypt the key to the role by following the steps at [Permissions to decrypt an AWS Secrets Manager secret for the vector store containing your knowledge base](encryption-kb.md#encryption-kb-3p).

## Permissions for AWS to manage a AWS KMS key for transient data storage during data ingestion
<a name="kb-permissions-kms-ingestion"></a>

To allow the creation of a AWS KMS key for transient data storage in the process of ingesting your data source, attach the following policy to your Amazon Bedrock Knowledge Bases service role. Replace the *\$1\$1Region\$1*, *\$1\$1AccountId\$1*, and *\$1\$1KeyId\$1* with the appropriate values.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kms:GenerateDataKey",
                "kms:Decrypt"
            ],
            "Resource": [
                "arn:aws:kms:us-east-1:123456789012:key/${KeyId}"
            ]
        }
    ]
}
```

------

## Permissions for AWS to manage a data sources from another user's AWS account.
<a name="kb-permissions-otherds"></a>

To allow the access to another user's AWS account, you must create a role that allows cross-account access to a Amazon S3 bucket in another user's account. Replace the *\$1\$1BucketName\$1*, *\$1\$1BucketOwnerAccountId\$1*, and *\$1\$1BucketNameAndPrefix\$1* with the appropriate values.

**Permissions Required on Knowledge Base role**

The knowledge base role that is provided during knowledge base creation `createKnowledgeBase` requires the following Amazon S3 permissions.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "S3ListBucketStatement",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        },
        {
            "Sid": "S3GetObjectStatement",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        }
    ]
}
```

------

If the Amazon S3 bucket is encrypted using a AWS KMS key, the following also needs to be added to the knowledge base role. Replace the *\$1\$1BucketOwnerAccountId\$1* and *\$1\$1Region\$1* with the appropriate values.

```
{
        "Sid": "KmsDecryptStatement",
        "Effect": "Allow",
        "Action": [
            "kms:Decrypt"
        ],
        "Resource": [
            "arn:aws:kms:${Region}:${BucketOwnerAccountId}:key/${KeyId}"
        ],
        "Condition": {
        "StringEquals": {
            "kms:ViaService": [
                "s3.${Region}.amazonaws.com"
            ]
        }
        }
    }
```

**Permissions required on a cross-account Amazon S3 bucket policy**

The bucket in the other account requires the following Amazon S3 bucket policy. Replace the *\$1\$1KbRoleArn\$1*, *\$1\$1BucketName\$1*, and *\$1\$1BucketNameAndPrefix\$1* with the appropriate values. 

------
#### [ JSON ]

****  

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement": [
      {
         "Sid": "ListBucket",
         "Effect": "Allow",
         "Principal": {
            "AWS": "123456789012"
         },
         "Action": [
            "s3:ListBucket"
         ],
         "Resource": [
            "arn:aws:s3:::amzn-s3-demo-bucket"
         ]
      },
      {
         "Sid": "GetObject",
         "Effect": "Allow",
         "Principal": {
            "AWS": "123456789012"
         },
         "Action": [
            "s3:GetObject"
         ],
         "Resource": [
            "arn:aws:s3:::amzn-s3-demo-bucket/*"
         ]
      }
   ]
}
```

------

**Permissions required on cross-account AWS KMS key policy**

If the cross-account Amazon S3 bucket is encrypted using a AWS KMS key in that account, the policy of the AWS KMS key requires the following policy. Replace the *\$1\$1KbRoleArn\$1* and *\$1\$1KmsKeyArn\$1* with the appropriate values.

```
{
    "Sid": "Example policy",
    "Effect": "Allow",
    "Principal": {
        "AWS": [
            "${KbRoleArn}"
        ]
    },
    "Action": [
        "kms:Decrypt"
    ],
    "Resource": "${KmsKeyArn}"
}
```

# Create a service role for Amazon Bedrock Flows in Amazon Bedrock
<a name="flows-permissions"></a>

To create and manage a flow in Amazon Bedrock, you must use a service role with the necessary permissions outlined on this page. You can use a service role that Amazon Bedrock automatically creates for you in the console or use one that you customize yourself.

**Note**  
If you use the service role that Amazon Bedrock automatically creates for you in the console, it will attach permissions dynamically if you add nodes to your flow and save the flow. If you remove nodes, however, the permissions won't be deleted, so you will have to delete the permissions you no longer need. To manage the permissions for the role that was created for you, follow the steps at [Modifying a role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_modify.html) in the IAM User Guide.

To create a custom service role for Amazon Bedrock Flows, create an IAM role by following the steps at [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html). Then attach the following permissions to the role.
+ Trust policy
+ The following identity-based permissions:
  + Access to the Amazon Bedrock base models that the flow will use. Add each model that's used in the flow to the `Resource` list.
  + If you invoke a model using Provisioned Throughput, permissions to access and invoke the provisioned model. Add each model that's used in the flow to the `Resource` list.
  + If you invoke a custom model, permissions to access and invoke the custom model. Add each model that's used in the flow to the `Resource` list.
  + Permissions based on the nodes that you add to the flow:
    + If you include prompt nodes that use prompts from Prompt management, you need permissions to access the prompt. Add each prompt that's used in the flow to the `Resource` list.
    + If you include knowledge base nodes, you need permissions to query the knowledge base. Add each knowledge base that's queried in the flow to the `Resource` list.
    + If you include agent nodes, you need permissions to invoke an alias of the agent. Add each agent that's invoked in the flow to the `Resource` list.
    + If you include S3 retrieval nodes, you need permissions to access the Amazon S3 bucket from which data will be retrieved. Add each bucket from which data is retrieved to the `Resource` list.
    + If you include S3 storage nodes, you need permissions to write to the Amazon S3 bucket in which output data will be stored. Add each bucket to which data is written to the `Resource` list.
    + If you include guardrails for a knowledge base node or a prompt node, you need permissions to apply the guardrails in a flow. Add each guardrail that's used in the flow to the `Resource` list.
    + If you include Lambda nodes, you need permissions to invoke the Lambda function. Add each Lambda function which needs to be invoked to the `Resource` list.
    + If you include Amazon Lex nodes, you need permissions to use the Amazon Lex bot. Add each bot alias which needs to be used to the `Resource` list.
    + If you encrypted any resource invoked in a flow, you need permissions to decrypt the key. Add each key to the `Resource` list.
+ If you encrypt the flow, you also need to attach a key policy to the KMS key that you use to encrypt the flow.

**Note**  
The following changes were recently implemented:  
Previously, AWS Lambda and Amazon Lex resources were invoked using the Amazon Bedrock service principal. This behavior is changing for flows created after 2024-11-22 and the Amazon Bedrock Flows service role will be used to invoke the AWS Lambda and Amazon Lex resources. If you created any flows that use either of these resources before 2024-11-22, you should update your Amazon Bedrock Flows service roles with AWS Lambda and Amazon Lex permissions.
Previously, Prompt management resources were rendered using the `bedrock:GetPrompt` action. This behavior is changing for flows created after 2024-11-22 and the `bedrock:RenderPrompt` action will be used to render the prompt resource. If you created any flows that use a prompt resource before 2024-11-22, you should update your Amazon Bedrock Flows service roles with `bedrock:RenderPrompt` permissions.
If you're using a service role that Amazon Bedrock automatically created for you in the console, Amazon Bedrock will attach the corrected permissions dynamically when you save the flow.

**Topics**
+ [Trust relationship](#flows-permissions-trust)
+ [Identity-based permissions for the flows service role.](#flows-permissions-identity)

## Trust relationship
<a name="flows-permissions-trust"></a>

Attach the following trust policy to the flow execution role to allow Amazon Bedrock to assume this role and manage a flow. Replace the *values* as necessary. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.

**Note**  
As a best practice, replace the *\$1* with a flow ID after you have created it.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "FlowsTrustBedrock",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "AWS:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:flow/*"
                }
            }
        }
    ]
}
```

------

## Identity-based permissions for the flows service role.
<a name="flows-permissions-identity"></a>

Attach the following policy to provide permissions for the service role, replacing *values* as necessary. The policy contains the following statements. Omit a statement if it isn't applicable to your use-case. The policy contains optional condition keys (see [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) and [AWS global condition context keys](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys)) in the `Condition` field that we recommend you use as a security best practice.
+ Access to the Amazon Bedrock base models that the flow will use. Add each model that's used in the flow to the `Resource` list.
+ If you invoke a model using Provisioned Throughput, permissions to access and invoke the provisioned model. Add each model that's used in the flow to the `Resource` list.
+ If you invoke a custom model, permissions to access and invoke the custom model. Add each model that's used in the flow to the `Resource` list.
+ Permissions based on the nodes that you add to the flow:
  + If you include prompt nodes that use prompts from Prompt management, you need permissions to access the prompt. Add each prompt that's used in the flow to the `Resource` list.
  + If you include knowledge base nodes, you need permissions to query the knowledge base. Add each knowledge base that's queried in the flow to the `Resource` list.
  + If you include agent nodes, you need permissions to invoke an alias of the agent. Add each agent that's invoked in the flow to the `Resource` list.
  + If you include S3 retrieval nodes, you need permissions to access the Amazon S3 bucket from which data will be retrieved. Add each bucket from which data is retrieved to the `Resource` list.
  + If you include S3 storage nodes, you need permissions to write to the Amazon S3 bucket in which output data will be stored. Add each bucket to which data is written to the `Resource` list.
  + If you include guardrails for a knowledge base node or a prompt node, you need permissions to apply the guardrails in a flow. Add each guardrail that's used in the flow to the `Resource` list.
  + If you include Lambda nodes, you need permissions to invoke the Lambda function. Add each Lambda function which needs to be invoked to the `Resource` list.
  + If you include Amazon Lex nodes, you need permissions to use the Amazon Lex bot. Add each bot alias which needs to be used to the `Resource` list.
  + If you encrypted any resource invoked in a flow, you need permissions to decrypt the key. Add each key to the `Resource` list.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "InvokeModel",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/ModelId"
            ]
        },
        {
            "Sid": "InvokeProvisionedThroughput",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:GetProvisionedModelThroughput"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:provisioned-model/ModelId"
            ]
        },
        {
            "Sid": "InvokeCustomModel",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:GetCustomModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:custom-model/ModelId"
            ]
        },
        {
            "Sid": "UsePromptFromPromptManagement",
            "Effect": "Allow",
            "Action": [
                "bedrock:RenderPrompt"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:prompt/PromptId"
            ]
        },
        {
            "Sid": "QueryKnowledgeBase",
            "Effect": "Allow",
            "Action": [
                "bedrock:Retrieve"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KnowledgeBaseId"
            ]
        },
        {
            "Sid": "InvokeAgent",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeAgent"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:agent-alias/AgentId/AgentAliasId"
            ]
        },
        {
            "Sid": "AccessS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        },
        {
            "Sid": "WriteToS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        },
        {
            "Sid": "GuardrailPermissions",
            "Effect": "Allow",
            "Action": [
                "bedrock:ApplyGuardrail"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:guardrail/GuardrailId"
            ]
        },
        {
            "Sid": "LambdaPermissions",
            "Effect": "Allow",
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Resource": [
                "arn:aws:lambda:us-east-1:123456789012:function:FunctionId"
            ]
        },
        {
            "Sid": "AmazonLexPermissions",
            "Effect": "Allow",
            "Action": [
                "lex:RecognizeUtterance"
            ],
            "Resource": [ 
                "arn:aws:lex:us-east-1:123456789012:bot-alias/BotId/BotAliasId"
            ]
        },
        {
            "Sid": "KMSPermissions",
            "Effect": "Allow",
            "Action": [
                "kms:GenerateDataKey",
                "kms:Decrypt"
            ],
            "Resource": [
                "arn:aws:kms:us-east-1:123456789012:key/KeyId"
            ],
             "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "123456789012"
                }
            }
        }
    ]
}
```

------

# Service role requirements for model evaluation jobs
<a name="model-evaluation-security-service-roles"></a>

To create a model evaluation job, you must specify a service role. A service role is an [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) that a service assumes to perform actions on your behalf. An IAM administrator can create, modify, and delete a service role from within IAM. For more information, see [Create a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) in the *IAM User Guide*. 

The required IAM actions and resource depend on the type of model evaluation job you are creating. Use the following sections to learn more about the required Amazon Bedrock,Amazon SageMaker AI, and Amazon S3 IAM actions, service principals, and resources. You can optionally choose to encrypt your data using AWS Key Management Service.

**Topics**
+ [Service role requirements for automatic model evaluation jobs](automatic-service-roles.md)
+ [Service role requirements for human-based model evaluation jobs](model-eval-service-roles.md)
+ [Required service role permissions for creating a model evaluation job that uses a judge model](judge-service-roles.md)
+ [Service role requirements for knowledge base evaluation jobs](rag-eval-service-roles.md)

# Service role requirements for automatic model evaluation jobs
<a name="automatic-service-roles"></a>

To create an automatic model evaluation job, you must specify a service role. The policy you attach grants Amazon Bedrock access to resources in your account, and allows Amazon Bedrock to invoke the selected model on your behalf.

You must also attach a trust policy that defines Amazon Bedrock as the service principal using `bedrock.amazonaws.com`. Each of the following policy examples shows you the exact IAM actions that are required based on each service invoked in an automatic model evaluation job.

To create a custom service role, see [Creating a role that uses a custom trust policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html) in the *IAM User Guide*.

**Required Amazon S3 IAM actions**  
The following policy example grants access to the S3 buckets where your model evaluation results are saved, and (optionally) access to any custom prompt datasets you have specified.

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
"Statement": [
    {
        "Sid": "AllowAccessToCustomDatasets",
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:ListBucket"
        ],
        "Resource": [
            "arn:aws:s3:::my_customdataset1_bucket",
            "arn:aws:s3:::my_customdataset1_bucket/myfolder",
            "arn:aws:s3:::my_customdataset2_bucket",
            "arn:aws:s3:::my_customdataset2_bucket/myfolder"
        ]
    },
    {
        "Sid": "AllowAccessToOutputBucket",
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:ListBucket",
            "s3:PutObject",
            "s3:GetBucketLocation",
            "s3:AbortMultipartUpload",
            "s3:ListBucketMultipartUploads"
        ],
        "Resource": [
            "arn:aws:s3:::my_output_bucket",
            "arn:aws:s3:::my_output_bucket/myfolder"
        ]
    }
]
}
```

------

**Required Amazon Bedrock IAM actions**  
You also need to create a policy that allows Amazon Bedrock to invoke the model you plan to specify in the automatic model evaluation job. To learn more about managing access to Amazon Bedrock models, see [Access Amazon Bedrock foundation models](model-access.md). In the `"Resource"` section of the policy, you must specify at least one ARN of a model you have access too. To use a model encrypted with customer managed key KMS key, you must add the required IAM actions and resources to the IAM service role policy. You must also add the service role to the AWS KMS key policy.

------
#### [ JSON ]

****  

```
{
		    "Version":"2012-10-17",		 	 	 
            "Statement": [
        {
            "Sid": "AllowAccessToBedrockResources",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream",
                "bedrock:CreateModelInvocationJob",
                "bedrock:StopModelInvocationJob",
                "bedrock:GetProvisionedModelThroughput",
                "bedrock:GetInferenceProfile", 
                "bedrock:ListInferenceProfiles",
                "bedrock:GetImportedModel",
                "bedrock:GetPromptRouter",
                "sagemaker:InvokeEndpoint"
            ],
            "Resource": [
                "arn:aws:bedrock:*::foundation-model/*",
                "arn:aws:bedrock:*:111122223333:inference-profile/*",
                "arn:aws:bedrock:*:111122223333:provisioned-model/*",
                "arn:aws:bedrock:*:111122223333:imported-model/*",
                "arn:aws:bedrock:*:111122223333:application-inference-profile/*",
                "arn:aws:bedrock:*:111122223333:default-prompt-router/*",
                "arn:aws:sagemaker:*:111122223333:endpoint/*",
                "arn:aws:bedrock:*:111122223333:marketplace/model-endpoint/all-access"
            ]
        }
    ]
}
```

------

**Service principal requirements**  
You must also specify a trust policy that defines Amazon Bedrock as the service principal. This allows Amazon Bedrock to assume the role. The wildcard (`*`) model evaluation job ARN is required so that Amazon Bedrock can create model evaluation jobs in your AWS account.

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
"Statement": [{
    "Sid": "AllowBedrockToAssumeRole",
    "Effect": "Allow",
    "Principal": {
        "Service": "bedrock.amazonaws.com"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
        "StringEquals": {
            "aws:SourceAccount": "111122223333"
        },
        "ArnEquals": {
            "aws:SourceArn": "arn:aws:bedrock:us-east-1:111122223333:evaluation-job/*"
        }
    }
}]
}
```

------

# Service role requirements for human-based model evaluation jobs
<a name="model-eval-service-roles"></a>

To create a model evaluation job that uses human evaluators, you must specify two service roles.

The following lists summarize the IAM policy requirements for each required service role that must be specified in the Amazon Bedrock console.

**Summary of IAM policy requirements for the Amazon Bedrock service role**
+ You must attach a trust policy which defines Amazon Bedrock as the service principal.
+ You must allow Amazon Bedrock to invoke the selected models on your behalf.
+ You must allow Amazon Bedrock to access the S3 bucket that holds your prompt dataset and the S3 bucket where you want the results saved.
+ You must allow Amazon Bedrock to create the required human loop resources in your account.
+ (Recommended) Use a `Condition` *block* to specify accounts that can access.
+ (Optional) You must allow Amazon Bedrock to decrypt your KMS key if you've encrypted your prompt dataset bucket or the Amazon S3 bucket where you want the results saved.

**Summary of IAM policy requirements for the Amazon SageMaker AI service role**
+ You must attach a trust policy which defines SageMaker AI as the service principal.
+ You must allow SageMaker AI to access the S3 bucket that holds your prompt dataset and the S3 bucket where you want the results saved.
+ (Optional) You must allow SageMaker AI to use your customer managed keys if you've encrypted your prompt dataset bucket or the location where you wanted the results.

To create a custom service role, see [Creating a role that uses a custom trust policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html) in the *IAM User Guide*.

**Required Amazon S3 IAM actions**  
The following policy example grants access to the S3 buckets where your model evaluation results are saved, and access to the custom prompt dataset you have specified. You need to attach this policy to both the SageMaker AI service role and the Amazon Bedrock service role.

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
"Statement": [
    {
        "Sid": "AllowAccessToCustomDatasets",
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:ListBucket"
        ],
        "Resource": [
            "arn:aws:s3:::custom-prompt-dataset"
        ]
    },
    {
        "Sid": "AllowAccessToOutputBucket",
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:ListBucket",
            "s3:PutObject",
            "s3:GetBucketLocation",
            "s3:AbortMultipartUpload",
            "s3:ListBucketMultipartUploads"
        ],
        "Resource": [
            "arn:aws:s3:::model_evaluation_job_output"
        ]
    }
]
}
```

------

**Required Amazon Bedrock IAM actions**  
To allow Amazon Bedrock to invoke the model you plan to specify in the automatic model evaluation job, attach the following policy to the Amazon Bedrock service role. In the `"Resource"` section of the policy, you must specify at least one ARN of a model you have access too. To use a model encrypted with customer managed key KMS key, you must add the required IAM actions and resources to the IAM service role. You must also add any required AWS KMS key policy elements.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowAccessToBedrockResources",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream",
                "bedrock:CreateModelInvocationJob",
                "bedrock:StopModelInvocationJob",
                "bedrock:GetProvisionedModelThroughput",
                "bedrock:GetInferenceProfile", 
                "bedrock:ListInferenceProfiles",
                "bedrock:GetImportedModel",
                "bedrock:GetPromptRouter",
                "sagemaker:InvokeEndpoint"
            ],
            "Resource": [
                "arn:aws:bedrock:*::foundation-model/*",
                "arn:aws:bedrock:*:111122223333:inference-profile/*",
                "arn:aws:bedrock:*:111122223333:provisioned-model/*",
                "arn:aws:bedrock:*:111122223333:imported-model/*",
                "arn:aws:bedrock:*:111122223333:application-inference-profile/*",
                "arn:aws:bedrock:*:111122223333:default-prompt-router/*",
                "arn:aws:sagemaker:*:111122223333:endpoint/*",
                "arn:aws:bedrock:*:111122223333:marketplace/model-endpoint/all-access"
            ]
        }
    ]
}
```

------

**Required Amazon Augmented AI IAM actions**  
You also must create a policy that allows Amazon Bedrock to create resources related to human-based model evaluation jobs. Because Amazon Bedrock creates the needed resources to start the model evaluation job, you must use `"Resource": "*"`. You must attach this policy to the Amazon Bedrock service role.

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
"Statement": [
    {
        "Sid": "ManageHumanLoops",
        "Effect": "Allow",
        "Action": [
            "sagemaker:StartHumanLoop",
            "sagemaker:DescribeFlowDefinition",
            "sagemaker:DescribeHumanLoop",
            "sagemaker:StopHumanLoop",
            "sagemaker:DeleteHumanLoop"
        ],
        "Resource": "*"
    }
]
}
```

------

**Service principal requirements (Amazon Bedrock)**  
You must also specify a trust policy that defines Amazon Bedrock as the service principal. This allows Amazon Bedrock to assume the role.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowBedrockToAssumeRole",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "111122223333"
                },
                "ArnEquals": {
                    "aws:SourceArn": "arn:aws:bedrock:us-east-1:111122223333:evaluation-job/*"
                }
            }
        }
    ]
}
```

------

**Service principal requirements (SageMaker AI)**  
You must also specify a trust policy that defines Amazon Bedrock as the service principal. This allows SageMaker AI to assume the role.

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
"Statement": [
{
  "Sid": "AllowSageMakerToAssumeRole",
  "Effect": "Allow",
  "Principal": {
    "Service": "sagemaker.amazonaws.com"
  },
  "Action": "sts:AssumeRole"
}
]
}
```

------

# Required service role permissions for creating a model evaluation job that uses a judge model
<a name="judge-service-roles"></a>

To create a model evaluation job that uses a LLM as judge, you must specify a service role. The policy you attach grants Amazon Bedrock access to resources in your account, and allows Amazon Bedrock to invoke the selected model on your behalf.

The trust policy defines Amazon Bedrock as the service principal using `bedrock.amazonaws.com`. Each of the following policy examples shows you the exact IAM actions that are required based on each service invoked in the model evaluation job

To create a custom service role as described below, see [Creating a role that uses a custom trust policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html) in the *IAM User Guide*.

## Required Amazon Bedrock IAM actions
<a name="judge-service-roles-br"></a>

You need to create a policy that allows Amazon Bedrock to invoke the models you plan to specify in the model evaluation job. To learn more about managing access to Amazon Bedrock models, see [Access Amazon Bedrock foundation models](model-access.md). In the `"Resource"` section of the policy, you must specify at least one ARN of a model you have access too. To use a model encrypted with customer managed key KMS key, you must add the required IAM actions and resources to the IAM service role policy. You must also add the service role to the AWS KMS key policy.

The service role must include access to at least one supported evaluator model. For a list of currently supported evaluator models, see [Supported models](evaluation-judge.md#evaluation-judge-supported).

------
#### [ JSON ]

****  

```
{
	"Version":"2012-10-17",		 	 	 
	"Statement": [
		{
			"Sid": "BedrockModelInvoke",
			"Effect": "Allow",
			"Action": [
				"bedrock:InvokeModel",
				"bedrock:CreateModelInvocationJob",
				"bedrock:StopModelInvocationJob"
			],
			"Resource": [
				"arn:aws:bedrock:us-east-1::foundation-model/*",
				"arn:aws:bedrock:us-east-1:111122223333:inference-profile/*",
				"arn:aws:bedrock:us-east-1:111122223333:provisioned-model/*",
				"arn:aws:bedrock:us-east-1:111122223333:imported-model/*"
			]
		}
	]
}
```

------

## Required Amazon S3 IAM actions and resources
<a name="judge-service-roles-s3"></a>

Your service role policy needs to include access to the Amazon S3 bucket where you want the output of model evaluation jobs saved, and access to the prompt dataset you have specified in your `CreateEvaluationJob` request or via the Amazon Bedrock console.

------
#### [ JSON ]

****  

```
{
	"Version":"2012-10-17",		 	 	 
	"Statement": [
		{
			"Sid": "FetchAndUpdateOutputBucket",
			"Effect": "Allow",
			"Action": [
				"s3:GetObject",
				"s3:ListBucket",
				"s3:PutObject",
				"s3:GetBucketLocation",
				"s3:AbortMultipartUpload",
				"s3:ListBucketMultipartUploads"
			],
			"Resource": [
				"arn:aws:s3:::my_customdataset1_bucket",
	            "arn:aws:s3:::my_customdataset1_bucket/myfolder",
	            "arn:aws:s3:::my_customdataset2_bucket",
				"arn:aws:s3:::my_customdataset2_bucket/myfolder"
			]
		}
	]
}
```

------

# Service role requirements for knowledge base evaluation jobs
<a name="rag-eval-service-roles"></a>

To create a knowledge base evaluation job, you must specify a service role. The policy that you attach to the role grants Amazon Bedrock access to resources in your account, and it allows Amazon Bedrock to do the following:
+ Invoke the models that you select for output generation with the `RetrieveAndGenerate` API action, and evaluate the knowledge base outputs.
+ Invoke the Amazon Bedrock Knowledge Bases `Retrieve` and `RetrieveAndGenerate` API actions on your knowledge base instance.

To create a custom service role, see [Creating a role that uses custom trust policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html) in the *IAM User Guide*.

**Required IAM actions for Amazon S3 access**  
The following example policy grants access to the S3 buckets where both of the following occur: 
+ You save your knowledge base evaluation results.
+ Amazon Bedrock reads your input dataset.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":
    [
        {
            "Sid": "AllowAccessToCustomDatasets",
            "Effect": "Allow",
            "Action":
            [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource":
            [
                "arn:aws:s3:::my_customdataset1_bucket",
                "arn:aws:s3:::my_customdataset1_bucket/myfolder",
                "arn:aws:s3:::my_customdataset2_bucket",
                "arn:aws:s3:::my_customdataset2_bucket/myfolder"
            ]
        },
        {
            "Sid": "AllowAccessToOutputBucket",
            "Effect": "Allow",
            "Action":
            [
                "s3:GetObject",
                "s3:ListBucket",
                "s3:PutObject",
                "s3:GetBucketLocation",
                "s3:AbortMultipartUpload",
                "s3:ListBucketMultipartUploads"
            ],
            "Resource":
            [
                "arn:aws:s3:::my_output_bucket",
                "arn:aws:s3:::my_output_bucket/myfolder"
            ]
        }
    ]
}
```

------

**Required Amazon Bedrock IAM actions**  
You also need to create a policy that allows Amazon Bedrock to do the following:

1. Invoke the models that you plan to specify for the following: 
   + Result generation with the `RetrieveAndGenerate` API action.
   + Evaluation of results.

   For the `Resource` key in the policy, you must specify at least one ARN of a model you have access to. To use a model that's encrypted with a customer-managed KMS key, you must add the required IAM actions and resources to the IAM service role policy. You must also add the service role to the AWS KMS key policy.

1. Call the `Retrieve` and `RetrieveAndGenerate` API actions. Note that, in the automated role creation in the console, we give permissions to both `Retrieve` and `RetrieveAndGenerate` API actions, regardless of the action you choose to evaluate for that job. By doing so, we give additional flexibility and reusability for that role. However, for added security, that automatically-created role is tied to a single knowledge base instance.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowSpecificModels",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel",
                "bedrock:InvokeModelWithResponseStream",
                "bedrock:CreateModelInvocationJob",
                "bedrock:StopModelInvocationJob",
                "bedrock:GetProvisionedModelThroughput",
                "bedrock:GetInferenceProfile",
                "bedrock:GetImportedModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/*",
                "arn:aws:bedrock:us-east-1:123456789012:inference-profile/*",
                "arn:aws:bedrock:us-east-1:123456789012:provisioned-model/*",
                "arn:aws:bedrock:us-east-1:123456789012:imported-model/*",
                "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/*"
            ]
        },
        {
            "Sid": "AllowKnowledgeBaseAPis",
            "Effect": "Allow",
            "Action": [
                "bedrock:Retrieve",
                "bedrock:RetrieveAndGenerate"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/knowledge-base-id"
            ]
        }
    ]
}
```

------

**Service Principal Requirements**  
You must also specify a trust policy that defines Amazon Bedrock as the service principal. This policy allows Amazon Bedrock to assume the role. The wildcard (`*`) model evaluation job ARN is required so that Amazon Bedrock can create model evaluation jobs in your AWS account.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowBedrockToAssumeRole",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnEquals": {
                    "aws:SourceArn": "arn:aws:bedrock:us-east-1:123456789012:evaluation-job/*"
                }
            }
        }
    ]
}
```

------

# Configure access to Amazon S3 buckets
<a name="s3-bucket-access"></a>

Multiple Amazon Bedrock features require access to data that is stored in Amazon S3 buckets. To access this data, you must configure the following permissions:


****  

| Use case | Permissions | 
| --- | --- | 
| Permissions to retrieve data from S3 bucket | s3:GetObjects3:ListBucket | 
| Permissions to write data to S3 bucket | s3:PutObject | 
| Permissions to decrypt KMS key that encrypted the S3 bucket | kms:Decryptkms:DescribeKey | 

The identities or resources to which you need to attach the above permissions depends on the following factors:
+ Multiple features in Amazon Bedrock use [service roles](security-iam-sr.md). If a feature uses a service role, you must configure the permissions such that the service role, rather than the user's IAM identity, has access to the S3 data. Some Amazon Bedrock features can automatically create a service role for you and attach the required [identity-based permissions](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies.html#policies_id-based) to the service role, if you use the AWS Management Console.
+ Some features in Amazon Bedrock allow an identity to access an S3 bucket in a different account. If S3 data needs to be accessed from a different account, the bucket owner must include the above [resource-based permissions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_resource-based) in an [S3 bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html) attached to the S3 bucket.

The following describes how to determine where you need to attach the necessary permissions to access S3 data:
+ IAM identity permissions
  + If you can auto-create a service role in the console, the permissions will be configured for the service role, so you don't need to configure it yourself.
  + If you prefer to use a custom service role or the identity that requires access isn't a service role, navigate to [Attach permissions to an IAM identity to allow it to access an Amazon S3 bucket](#s3-bucket-access-identity) to learn how to create an identity-based policy with the proper permissions.
+ Resource-based permissions
  + If the identity requires access to S3 data in the same account, you don't need attach an S3 bucket policy to the bucket containing the data.
  + If the identity requires access to S3 data in a different account, navigate to [Attach a bucket policy to an Amazon S3 bucket to allow another account to access it](#s3-bucket-access-cross-account) to learn how to create an S3 bucket policy with the proper permissions.
**Important**  
Automatic creation of a service role in the AWS Management Console attaches the proper identity-based permissions to the role, but you still must configure the S3 bucket policy if the identity that requires access to it is in a different AWS account.

For more information, see the following links:
+ To learn more about controlling access to data in Amazon S3, see [Access control in Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-management.html).
+ To learn more about Amazon S3 permissions, see [Actions defined by Amazon S3](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-actions-as-permissions).
+ To learn more about AWS KMS permissions, see [Actions defined by AWS Key Management Service](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awskeymanagementservice.html#awskeymanagementservice-actions-as-permissions).

Proceed through the topics that pertain to your use case:

**Topics**
+ [Attach permissions to an IAM identity to allow it to access an Amazon S3 bucket](#s3-bucket-access-identity)
+ [Attach a bucket policy to an Amazon S3 bucket to allow another account to access it](#s3-bucket-access-cross-account)
+ [(Advanced security option) Include conditions in a statement for more fine-grained access](#s3-bucket-access-conditions)

## Attach permissions to an IAM identity to allow it to access an Amazon S3 bucket
<a name="s3-bucket-access-identity"></a>

This topic provides a template for a policy to attach to an IAM identity. The policy includes the following statements defining permissions to grant an IAM identity access to an S3 bucket:

1. Permissions to retrieve data from an S3 bucket. This statement also includes a condition using the `s3:prefix` [condition key](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-policy-keys) to restrict access to a specific folder in the bucket. For more information about this condition, see the **User policy** section in [Example 2: Getting a list of objects in a bucket with a specific prefix](https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html#condition-key-bucket-ops-2).

1. (If you need to write data to an S3 location) Permissions to write data to an S3 bucket. This statement also includes a condition using the `aws:ResourceAccount` [condition key](https://docs.aws.amazon.com//IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount) to restrict access to requests sent from a specific AWS account.

1. (If the S3 bucket is encrypted with an KMS key) Permissions to describe and decrypt the KMS key that encrypted the S3 bucket.
**Note**  
If your S3 bucket is versioning-enabled, each object version that you upload by using this feature can have its own encryption key. You're responsible for tracking which encryption key was used for which object version.

Add, modify, and remove the statements, resources, and conditions in the following policy and replace *\$1\$1values\$1* as necessary:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ReadS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::${S3Bucket}",
                "arn:aws:s3:::${S3Bucket}/*"
            ]
        },
        {
            "Sid": "WriteToS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::${S3Bucket}",
                "arn:aws:s3:::${S3Bucket}/*"
            ]
        },
        {
            "Sid": "DecryptKMSKey",
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt",
                "kms:DescribeKey"
            ],
            "Resource": "arn:aws:kms:us-east-1:123456789012:key/${KMSKeyId}"
        }
    ]
}
```

------

After modifying the policy to your use case, attach it to the service role (or IAM identity) that requires access to the S3 bucket. To learn how to attach permissions to an IAM identity, see [Adding and removing IAM identity permissions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html).

## Attach a bucket policy to an Amazon S3 bucket to allow another account to access it
<a name="s3-bucket-access-cross-account"></a>

This topic provides a template for a resource-based policy to attach to an S3 bucket to allow an IAM identity to access data in the bucket. The policy includes the following statements defining permissions for an identity to access the bucket:

1. Permissions to retrieve data from an S3 bucket.

1. (If you need to write data to an S3 location) Permissions to write data to an S3 bucket.

1. (If the S3 bucket is encrypted with an KMS key) Permissions to describe and decrypt the KMS key that encrypted the S3 bucket.
**Note**  
If your S3 bucket is versioning-enabled, each object version that you upload by using this feature can have its own encryption key. You're responsible for tracking which encryption key was used for which object version.

The permissions are similar to the identity-based permissions described in [Attach permissions to an IAM identity to allow it to access an Amazon S3 bucket](#s3-bucket-access-identity). However, each statement also requires you to specify the identity for which to grant permissions to the resource in the `Principal` field. Specify the identity (with most features in Amazon Bedrock, this is the service role) in the `Principal` field. Add, modify, and remove the statements, resources, and conditions in the following policy and replace *\$1\$1values\$1* as necessary:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ReadS3Bucket",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/ServiceRole"
            },
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::${S3Bucket}",
                "arn:aws:s3:::${S3Bucket}/*"
            ]
        },
        {
            "Sid": "WriteToS3Bucket",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/ServiceRole"
            },
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::${S3Bucket}",
                "arn:aws:s3:::${S3Bucket}/*"
            ]
        },
        {
            "Sid": "DecryptKMSKey",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111122223333:role/ServiceRole"
            },
            "Action": [
                "kms:Decrypt",
                "kms:DescribeKey"
            ],
            "Resource": "arn:aws:kms:us-east-1:123456789012:key/${KMSKeyId}"
        }
    ]
}
```

------

After modifying the policy to your use case, attach it to the S3 bucket. To learn how to attach a bucket policy to an S3 bucket, see [Adding a bucket policy by using the Amazon S3 console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html).

## (Advanced security option) Include conditions in a statement for more fine-grained access
<a name="s3-bucket-access-conditions"></a>

For greater control over the identities that can access your resources, you can include conditions in a policy statement. The policy in this topic provides an example that uses the following condition keys:
+ `s3:prefix` – An S3 condition key that restricts access to a specific folder in an S3 bucket. For more information about this condition key, see the **User policy** section in [Example 2: Getting a list of objects in a bucket with a specific prefix](https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html#condition-key-bucket-ops-2).
+ `aws:ResourceAccount` – A global condition key that restricts access to requests from a specific AWS account.

The following policy restricts read access to the *my-folder* folder in the *amzn-s3-demo-bucket* S3 bucket and restricts write access for the *amzn-s3-demo-destination-bucket* S3 bucket to requests from the AWS account with the ID *111122223333*:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ReadS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition" : {
                "StringEquals" : {
                    "s3:prefix": "my-folder" 
                }
            }
        },
        {
            "Sid": "WriteToS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-destination-bucket",
                "arn:aws:s3:::amzn-s3-demo-destination-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "111122223333"
                }
            }
        }
    ]
}
```

------

To learn more about conditions and condition keys, see the following links:
+ To learn about conditions, see [IAM JSON policy elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html) in the IAM User Guide.
+ To learn about condition keys specific to S3, see [Condition keys for Amazon S3](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-policy-keys) in the Service Authorization Reference.
+ To learn about global condition keys used across AWS services, see [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount).

# Troubleshooting Amazon Bedrock identity and access
<a name="security_iam_troubleshoot"></a>

Use the following information to help you diagnose and fix common issues that you might encounter when working with Amazon Bedrock and IAM.

**Topics**
+ [I am not authorized to perform an action in Amazon Bedrock](#security_iam_troubleshoot-no-permissions)
+ [I am not authorized to perform iam:PassRole](#security_iam_troubleshoot-passrole)
+ [I want to allow people outside of my AWS account to access my Amazon Bedrock resources](#security_iam_troubleshoot-cross-account-access)

## I am not authorized to perform an action in Amazon Bedrock
<a name="security_iam_troubleshoot-no-permissions"></a>

If you receive an error that you're not authorized to perform an action, your policies must be updated to allow you to perform the action.

The following example error occurs when the `mateojackson` IAM user tries to use the console to view details about a fictional `my-example-widget` resource but doesn't have the fictional `bedrock:GetWidget` permissions.

```
User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: bedrock:GetWidget on resource: my-example-widget
```

In this case, the policy for the `mateojackson` user must be updated to allow access to the `my-example-widget` resource by using the `bedrock:GetWidget` action.

If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials.

## I am not authorized to perform iam:PassRole
<a name="security_iam_troubleshoot-passrole"></a>

If you receive an error that you're not authorized to perform the `iam:PassRole` action, your policies must be updated to allow you to pass a role to Amazon Bedrock.

Some AWS services allow you to pass an existing role to that service instead of creating a new service role or service-linked role. To do this, you must have permissions to pass the role to the service.

The following example error occurs when an IAM user named `marymajor` tries to use the console to perform an action in Amazon Bedrock. However, the action requires the service to have permissions that are granted by a service role. Mary does not have permissions to pass the role to the service.

```
User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole
```

In this case, Mary's policies must be updated to allow her to perform the `iam:PassRole` action.

If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials.

## I want to allow people outside of my AWS account to access my Amazon Bedrock resources
<a name="security_iam_troubleshoot-cross-account-access"></a>

You can create a role that users in other accounts or people outside of your organization can use to access your resources. You can specify who is trusted to assume the role. For services that support resource-based policies or access control lists (ACLs), you can use those policies to grant people access to your resources.

To learn more, consult the following:
+ To learn whether Amazon Bedrock supports these features, see [How Amazon Bedrock works with IAM](security_iam_service-with-iam.md).
+ To learn how to provide access to your resources across AWS accounts that you own, see [Providing access to an IAM user in another AWS account that you own](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html) in the *IAM User Guide*.
+ To learn how to provide access to your resources to third-party AWS accounts, see [Providing access to AWS accounts owned by third parties](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) in the *IAM User Guide*.
+ To learn how to provide access through identity federation, see [Providing access to externally authenticated users (identity federation)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_federated-users.html) in the *IAM User Guide*.
+ To learn the difference between using roles and resource-based policies for cross-account access, see [Cross account resource access in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html) in the *IAM User Guide*.