Deploying AWS Bedrock Agents with Pulumi

Introduction
This guide shows how to deploy AWS Bedrock Agents using Pulumi and TypeScript.
Prerequisites
AWS Account with Bedrock access
Node.js and npm installed
Pulumi CLI installed
Project Setup
- Generate Project with Pulumi
pulumi new aws-typescript
cd bedrock-agent-project
This 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
Pulumi Configuration
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 };
Required IAM Role
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
Deployment
Deploy your Bedrock Agent using this commandpulumi up
Testing
After deployment:
Go to AWS Bedrock console
Navigate to Agents
Find your deployed agent
Test using the built-in chat interface
Cleaning
To clean up, don’t forget to run the command pulumi down
Conclusion
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/



