How do I give cross-account access to the Amazon Bedrock API?
I want to use the Amazon Bedrock API across several AWS accounts.
Short description
When you use the Amazon Bedrock API across accounts, you manage permissions for the API client in one account, Account B. You invoke foundation models accessible in another account, Account A.
Important: Before you set up cross-account access, confirm that you are able to access the foundation models in Account A. For Anthropic models, complete the one-time First Time Use form. For more information, see Simplified model access in Amazon Bedrock.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
In the following resolution, Account A is the account where you invoke foundation models. Account B is the account that contains the compute resource that calls the Amazon Bedrock API in Account A. Compute resources can include an AWS Lambda function, Amazon Elastic Compute Cloud (Amazon EC2) instance, Amazon Elastic Container Service (Amazon ECS) task, or Amazon SageMaker AI notebook.
Account A: Create an IAM role with Bedrock permissions
To create an AWS Identity and Access Management (IAM) role in Account A that provides access to Amazon Bedrock, complete the following steps.
- Open the IAM console.
- Create an IAM role.
- Attach an identity-based policy to the role. Scope permissions to the specific actions and models required. Example:
Note: Replace Account-A-ID with the AWS Account ID of Account A.{ "Version": "2012-10-17", "Statement": [ { "Sid": "BedrockInvokeAccess", "Effect": "Allow", "Action": [ "bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream" ], "Resource": [ "arn:aws:bedrock:*::foundation-model/*", "arn:aws:bedrock:*:Account-A-ID:inference-profile/*" ] } ] }
Include the following elements in the policy if you require them:
- To restrict access to a single model, replace foundation-model/* with foundation-model/ and keep the AWS Region as a wildcard. For example: arn:aws:bedrock:*::foundation-model/. Don't restrict the foundation model ARN to a single Region if you use a cross-Region inference profile. The policy must allow the model in all destination Regions that the profile can route to. For a list of model IDs, see Supported foundation models in Amazon Bedrock.
- Include the inference-profile/* resource only if you require cross-region inference.
- For the Converse API, use the bedrock:InvokeModel permission. ConverseStream requires bedrock:InvokeModelWithResponseStream.
- For third-party models delivered through AWS Marketplace, add aws-marketplace:Subscribe and aws-marketplace:ViewSubscriptions permissions to the IAM role. For more information, see Resolve AWS Marketplace permission errors in Bedrock.
For more information, see Identity-based policy examples for Amazon Bedrock.
Configure the trust policy on the role to allow a specific role in Account B to assume it.
Example:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::Account-B-ID:role/RoleB" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "unique-external-id" } } } ] }
Note: Replace Account-B-ID with the AWS account ID of Account B, RoleB with the IAM role name in Account B that needs access, and unique-external-id with your external ID.
Note: The ExternalId condition is a best practice when you grant access to accounts outside your organization. It helps prevent the confused deputy problem. If both accounts belong to the same AWS Organization, you can omit this condition.
Account B: Create an IAM role with permission to assume the role in Account A
To allow the compute resource in Account B to assume the role in Account A, complete the following steps:
- Open the IAM console.
- Create or identify the IAM role that the compute resource uses.
- Attach the following identity-based policy to allow the role in Account B to assume the role in Account A:
Note: Replace Account-A-ID with the AWS Account ID of your Account A, and BedrockCrossAccountRole with the name of your role in Account A.{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::Account-A-ID:role/BedrockCrossAccountRole" } ] }
For more information, see Cross account resource access in IAM.
Test the setup from Account B
After you configure both roles, run the following Python code from the compute resource in Account B to test the setup. The code assumes the role in Account A and calls the Amazon Bedrock API. For production implementations, see AWS SDK for Python (Boto3) credentials guide and Converse API examples.
import boto3 # ARN of the role in Account A role_to_assume = 'arn:aws:iam::<Account A ID>:role/BedrockCrossAccountRole' # Assume the role in Account A using STS sts_client = boto3.client('sts') try: assumed_role = sts_client.assume_role( RoleArn=role_to_assume, RoleSessionName='CrossAccountBedrockSession', ExternalId='<unique-external-id>' # Include only if ExternalId is configured in the trust policy ) except Exception as e: print(f"Error assuming role: {e}") raise credentials = assumed_role['Credentials'] # Create a Bedrock Runtime client with the temporary credentials bedrock_client = boto3.client( 'bedrock-runtime', region_name='region', aws_access_key_id=credentials['AccessKeyId'], aws_secret_access_key=credentials['SecretAccessKey'], aws_session_token=credentials['SessionToken'] ) # Example: Invoke a model using the Converse API response = bedrock_client.converse( modelId='model-id', messages=[ { "role": "user", "content": [{"text": "Hello, this is a cross-account test."}] } ], inferenceConfig={ "maxTokens": 512 } ) print(response['output']['message']['content'][0]['text'])
Note: Replace region with the Region where the model is invoked. Replace model-id with the ID of the model.
Include the following elements in your code if you require them:
- Include the ExternalId parameter in assume_role only if an ExternalId condition was configured in the trust policy.
- For model-specific requests, use invoke_model instead of the Converse API.
- If you receive a "ValidationException" error that states that on-demand throughput isn't supported, replace the modelId with the inference profile ID. For more information, see Supported Regions and models for cross-Region inference.
Note: For current model IDs, see Supported foundation models in Amazon Bedrock.
Test with cross-region inference (optional)
If the IAM policy includes inference-profile/* and cross-region inference is required, replace the modelId with a cross-region inference profile ID.
Example:
# Replace the modelId with a cross-region inference profile response = bedrock_client.converse( modelId='inference-profile-id', messages=[ { "role": "user", "content": [{"text": "Hello from cross-region inference."}] } ], inferenceConfig={ "maxTokens": 512 } )
Note: Replace inference-profile-id with the ID of your inference profile.
The IAM role in Account A must allow bedrock:InvokeModel on the inference profile ARN and the foundation model ARN. The IAM role must provide these permissions in all destination Regions that the profile can route to.
For more information, see Cross-Region inference in Amazon Bedrock.
Best practices
When you set up permissions for cross-account access, take the following actions:
- Use least privilege. Scope the IAM policy to specific Bedrock actions and model ARNs, and don't attach AmazonBedrockFullAccess. For more information, see Security best practices in IAM.
- Set appropriate session duration with DurationSeconds. Because you're role chaining when Account B uses its role credentials to assume the role in Account A, the maximum session duration is 1 hour.
- Control access with SCPs. Use Service Control Policies for organization-wide guardrails. If your SCPs restrict Bedrock to specific Regions, then cross-region inference profiles can fail with an "AccessDeniedException" error. Either allow all destination Regions or exclude Bedrock from the Region restriction.
- Monitor with AWS CloudTrail. Check CloudTrail for AssumeRole events in Account B and InvokeModel events in Account A.
Related information
How Amazon Bedrock works with IAM
Prerequisites for running model inference
Troubleshoot InvokeModel API errors in Amazon Bedrock
Troubleshooting Amazon Bedrock API Error Codes
Simplify multi-account access to Amazon Bedrock models with managed entitlements
- Tags
- Amazon Bedrock
- Language
- English
Related videos


This article was reviewed and updated on 2026-11-02.
Relevant content
- Accepted Answer
asked a year ago
AWS OFFICIALUpdated 2 months ago