Connect AWS Bedrock to AI Runtime Control with an IAM role
Use AI Runtime Control (ARC) to call models on AWS Bedrock without storing long-lived AWS credentials by allowing ARC to assume an IAM role in your AWS account.
In this tutorial, you'll connect AWS Bedrock to AI Runtime Control (ARC) using AWS IAM authentication. Instead of giving ARC an API key, you'll create a role in your AWS account that ARC is allowed to assume, give that role permission to call Bedrock models, and send a test request through ARC to confirm everything works.
By the end, you'll understand how the trust policy and the permissions policy work together, and where to look when a request is denied.
Before you begin
This tutorial assumes you've already gotten access to ARC and have completed the steps to get started using it. You'll also need the following:
- The Superuser role. Other account roles can't access ARC.
- Access to an AWS account with permission to create IAM roles and policies.
- Bedrock model access in the AWS region you plan to use. Some models, including Anthropic models, require a one-time use case submission in the Bedrock console before you can call them.
- A virtual key in ARC to test with.
Why use an IAM role
With an IAM role, ARC never holds a long-lived AWS credential. When ARC needs to call Bedrock, it asks AWS for temporary credentials by assuming your role, and AWS only allows that if your role says ARC is trusted. You stay in control from your own AWS account, and you can change the role's permissions or revoke ARC's access at any time without touching ARC.
Two policies on the role make this work:
- The trust policy controls who can assume the role. Yours will trust ARC, and only when ARC presents your unique external ID.
- The permissions policy controls what the role can do once it's assumed. Yours will allow calling Bedrock models.
Most setup problems come from mixing these two up, so it helps to keep them separate as you go.
Step 1: Start adding the provider in ARC
Start in ARC, because it generates the values you'll need in AWS.
- Log in to the Fastly control panel.
- Go to Tools > AI Runtime Control.
- Click the Providers tab.
- Click Add, then select AWS Bedrock.
- For Authentication type, select AWS IAM. ARC displays a Role ARN and an External ID.
- Click the clipboard next to each value and paste them somewhere you can copy from later.
Keep this page open. You'll come back to it in Step 4.
IMPORTANT: The external ID is unique to your account. It isn't a password, but avoid sharing it publicly or including it in screenshots.
Step 2: Create the role in AWS
Next, create the role that ARC will assume and attach a trust policy that allows only ARC to assume it.
In the AWS console, open IAM.
In the left navigation, click Roles, then click Create role.
For Trusted entity type, select Custom trust policy. Don't select AWS service, which creates a role for an AWS service instead of for ARC.
Replace the policy in the editor with the following, filling in the two values you copied from ARC:
1234567891011121314151617{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": {"AWS": "<Role ARN from ARC>"},"Action": "sts:AssumeRole","Condition": {"StringEquals": {"sts:ExternalId": "<External ID from ARC>"}}}]}Click Next.
Step 3: Give the role permission to call Bedrock
Now attach a permissions policy that lets the role call Bedrock models.
On the Add permissions page, select Create inline policy.
Switch the editor to JSON and replace its contents with the following:
1234567891011121314151617181920212223{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["bedrock:InvokeModel","bedrock:InvokeModelWithResponseStream"],"Resource": ["arn:aws:bedrock:*::foundation-model/*","arn:aws:bedrock:*:*:inference-profile/*"]},{"Effect": "Allow","Action": ["bedrock-mantle:CreateInference"],"Resource": "arn:aws:bedrock-mantle:*:*:project/*"}]}Click Next, enter a policy name (for example,
ArcBedrockInvoke), and continue.Enter a role name that makes its purpose clear later (for example,
FastlyArcAccess), and update the description to match.On the review page, confirm the trust policy shows the ARC role ARN and your external ID, then click Create role.
Open the role you just created and copy its ARN from the top of the page.
NOTE: This policy allows any Bedrock model in any region, which keeps setup simple. For production, consider limiting Resource to the regions and models you actually use.
Step 4: Finish adding the provider in ARC
Return to the ARC page you left open in Step 1.
- In the Customer role ARN field, paste the ARN of the role you created.
- In the Region field, enter the region code of the AWS region where you enabled Bedrock model access (for example,
us-east-1). - Under Model permissions, do one of the following:
- To make every model available for this provider, select Allow all models.
- To limit access to specific models, select Limit model access and then select which models to allow.
- Click Save. The new provider appears on the Providers tab.
IMPORTANT: The region in ARC must match the region where your models are enabled. If they don't match, ARC can assume your role, but model requests will fail.
Step 5: Send a test request
Make sure your virtual key routes to the AWS Bedrock provider you just added. To check, edit the key and confirm that AWS Bedrock is selected in the Select provider menu in the Provider Routing & Failover area. Then send a request.
Store your virtual key in an environment variable. This command prompts for the key without displaying it or saving it to your shell history. Paste your key and press Enter.
$ read -rs ARC_API_KEY && export ARC_API_KEYSend the request:
$ curl -i "https://arc.fastly.app/v1/chat/completions" \ -H "Authorization: Bearer $ARC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "your-model-id", "messages": [ {"role": "user", "content": "Say hello and tell me which model you are."} ], "max_tokens": 100 }'Replace your-model-id with the ID of a Bedrock model that you allowed on the provider, as recognized by ARC.
A 200 response with the model's reply means your setup is complete.
Troubleshooting
When a request fails, the error message usually indicates whether the error originated from AWS or ARC. Specifically, look for errors that mention:
sts:AssumeRole. ARC couldn't assume your role. Check that the trust policy uses the exact Role ARN and External ID from ARC, and that you selected Custom trust policy when creating the role.- A role not being authorized to perform an action. ARC assumed your role, but the permissions policy doesn't allow the request. The error names the missing action. Add it to your inline policy.
- On-demand throughput not being supported. The model can only be called through a cross-region inference profile.
- The model being unavailable or inaccessible Model access isn't enabled in the region you set in ARC. Check the Bedrock console in that region.
What's next
You've connected AWS Bedrock to ARC without storing AWS credentials in ARC. From here, you can:
- connect your application to ARC with your virtual key, so its requests route to your Bedrock models.
- manage your providers, including editing the region or model permissions for your Bedrock provider.
- manage your virtual keys to control which keys can use your Bedrock models.
