Deploying AWS Bedrock Agents with Pulumi

I am a french Developer, working for a french startup :) i like video games, computers and drinking Ricoré
Search for a command to run...

I am a french Developer, working for a french startup :) i like video games, computers and drinking Ricoré
No comments yet. Be the first to comment.
AWS Bedrock AgentCore lets you deploy agents as managed containerized runtimes. This guide shows how to automate this deployment using Pulumi and Docker. What You'll Deploy Docker container with your agent code Amazon ECR to store the image Bedroc...

Starting My Homelab Journey with a Raspberry Pi 4B

I recently discovered Docker compose profiles and wanted to share it as it can be useful to someone else. Docker Compose profiles let you control which services run without modifying your docker-compose.yml. They’re useful for separating optional s...

These days, i’m using AWS Bedrock to create Agents.And i faced this error when testing my agents many times so i decided to write down the workaround that i found. An error occurred (dependencyFailedException) when calling the InvokeAgent operation: ...

This guide shows how to deploy AWS Bedrock Agents using Pulumi and TypeScript.
AWS Account with Bedrock access
Node.js and npm installed
Pulumi CLI installed
pulumi new aws-typescriptcd bedrock-agent-projectThis creates a complete TypeScript project with:
package.json with all dependencies
Pulumi.yaml configuration
index.ts entry point
TypeScript configuration
Project Structure
bedrock-agent-project/
├── package.json
├── Pulumi.yaml
├── index.ts
├── tsconfig.json
└── agent/
├── agent-deploy.ts
└── instructions.txt
Complete the file Pulumi.yaml with the following content:
name: My first agent
description: "Stack used to deploy my agent"
config:
aws_region: us-east-1
aws_accountId: "123456789012"
Replace 123456789012 with your actual AWS account ID and the region by the one you want to use
agent/agent-deploy.ts
import as pulumi from "@pulumi/pulumi";
import as aws from "@pulumi/aws";
// Configuration
const config = new pulumi.Config();
const awsRegion = config.require("aws_region");
const accountId = config.require("aws_accountId");
const stack = pulumi.getStack();
// Create Bedrock Agent
const bedrockAgent = new aws.bedrock.AgentAgent(my-agent-${stack}, {
agentName: my-agent-${stack},
description: "A helpful AI assistant",
agentResourceRoleArn: "arn:aws:iam::YOUR_ACCOUNT_ID:role/YOUR_BEDROCK_EXECUTION_ROLE", // Replace with your IAM role ARN
idleSessionTtlInSeconds: 500,
foundationModel: arn:aws:bedrock:${awsRegion}:${accountId}:inference-profile/eu.claude-3-5-sonnet-20241022-v2:0,
instruction: "You are a helpful assistant"
});
export const agentId = bedrockAgent.id;
export const agentArn = bedrockAgent.agentArn;
index.ts
Replace the default content with:
import { agentId, agentArn } from "./agent/agent-deploy";
export { agentId, agentArn };
Important: You must create the IAM role before deploying the agent, otherwise the deployment will fail.
Create IAM Role
Go to AWS IAM Console
Create a new role with these settings:
Trusted entity: AWS service
Service: Bedrock
Use case: Bedrock - Agents
Attach this policy to the role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel"
],
"Resource": "*"
}
]
}
Name your role (for example, MyBedrockAgentRole)
Update the agentResourceRoleArn in your code with the full ARN
Deploy your Bedrock Agent using this commandpulumi up
After deployment:
Go to AWS Bedrock console
Navigate to Agents
Find your deployed agent
Test using the built-in chat interface
To clean up, don’t forget to run the command pulumi down
That’s it!
You now have a deployed Bedrock Agent that can have conversations with users. The agent uses the Claude 3.5 Sonnet model and follows the instructions you provided.
Useful link: https://www.pulumi.com/registry/packages/aws/api-docs/bedrock/agentagent/