mastra-bedrock
Mastra + Amazon Bedrock
Wire a Mastra agent to Amazon Bedrock, and deploy it to AWS Bedrock AgentCore.
Verify before writing code
This builds on the mastra skill's rule: never trust cached Mastra API knowledge. Confirm the installed @mastra/core version and, when a model ID matters, that the model is enabled in the target Bedrock account/region.
Bedrock is not in Mastra's model router
Mastra's "provider/model" string router has no Bedrock provider — do not guess a bedrock/... string. Bedrock is used the other supported way: pass an AI SDK provider instance as the agent's model. MastraModelConfig accepts LanguageModelV1–V4, which the AI SDK Bedrock provider satisfies.
npm install @ai-sdk/amazon-bedrock @aws-sdk/credential-providers
Use the default credential chain
Build the provider with fromNodeProviderChain(). This is the load-bearing choice: the credential chain resolves credentials the standard AWS way — env vars, shared config (~/.aws), SSO, and the container/EC2/AgentCore execution role. The same code runs unchanged locally and deployed — locally it uses your AWS CLI session; on AgentCore it uses the runtime's IAM role. No key branching, no code diff between environments.