Deploying AWS Bedrock AgentCore 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.
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-t...

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: ...

AWS Bedrock AgentCore lets you deploy agents as managed containerized runtimes.
This guide shows how to automate this deployment using Pulumi and Docker.
Docker container with your agent code
Amazon ECR to store the image
Bedrock AgentCore Runtime to run your agent
# agents/my_agent/api.py
from fastapi import FastAPI
from langchain_openai import ChatOpenAI
import uvicorn
app = FastAPI()
@app.post("/invoke")
def invoke(input_data: dict):
llm = ChatOpenAI(model="gpt-4")
response = llm.invoke(input_data["input"])
return {"output": response.content}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8080)
# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# Run the agent
python agents/my_agent/api.py
Test with curl:
curl -X POST http://localhost:8080/invoke \
-H "Content-Type: application/json" \
-d '{"input": "Hello, what is AI?"}'
Example response:
{
"output": "AI, or Artificial Intelligence, refers to..."
}
FROM --platform=linux/arm64 ghcr.io/astral-sh/uv:python3.13-bookworm-slim
WORKDIR /app
# Copy dependencies
COPY pyproject.toml uv.lock
COPY agents ./agents
# Install dependencies
RUN uv sync --frozen --no-cache
EXPOSE 8080
# Start the agent API
CMD uv run uvicorn agents.my_agent.api:app --host 0.0.0.0 --port 8080
# Login to ECR
aws ecr get-login-password --region eu-west-1 | \
docker login --username AWS --password-stdin <account>.dkr.ecr.eu-west-1.amazonaws.com
# Build for ARM64
docker buildx build \
--platform linux/arm64 \
-t <account>.dkr.ecr.eu-west-1.amazonaws.com/my-agents:my_agent_v1 \
--load \
.
# Push to ECR
docker push <account>.dkr.ecr.eu-west-1.amazonaws.com/my-agents:my_agent_v1
# __main__.py
import pulumi
import pulumi_aws as aws
# Load config
config = pulumi.Config()
region = config.require("aws_region")
bedrock_role_arn = config.require("bedrock_role_arn")
# Get existing ECR repository
ecr_repo = aws.ecr.get_repository(name="my-agents")
# Build image URI
image_uri = f"{ecr_repo.repository_url}:my_agent_v1"
# Deploy to Bedrock AgentCore
runtime = aws.bedrock.AgentcoreAgentRuntime(
"my_agent_runtime",
agent_runtime_name="my_agent",
agent_runtime_artifact={
"artifact_type": "Docker",
"docker_uri": image_uri,
},
role_arn=bedrock_role_arn,
environment_variables=[
{"name": "AWS_REGION", "value": region},
{"name": "ENV", "value": "production"},
],
)
# Export outputs
pulumi.export("runtime_name", runtime.agent_runtime_name)
pulumi.export("runtime_arn", runtime.arn)
# Set configuration
pulumi config set aws:region eu-west-1
pulumi config set aws_region eu-west-1
pulumi config set bedrock_role_arn arn:aws:iam::123456:role/AmazonBedrockExecutionRoleForAgents
# Deploy
pulumi up
ARM64 Required: Bedrock AgentCore only supports ARM64 architecture.
Always use --platform linux/arm64.
Runtime Naming Rules:
Must start with a letter
Only alphanumeric characters and underscores
Max 48 characters
IAM Role Permissions:
The Bedrock role needs:
ecr:GetAuthorizationToken
ecr:BatchGetImage
logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents
Go to AWS Console → Amazon Bedrock AgentCore
Navigate to Agent runtime
Find your runtime in the list
Choose Test endpoint to interact with it