Deploy AI brokers on Amazon Bedrock AgentCore utilizing GitHub Actions
Not too long ago, AWS introduced Amazon Bedrock AgentCore, a versatile service that helps builders seamlessly create and handle AI brokers throughout completely different frameworks and fashions, whether or not hosted on Amazon Bedrock or different environments. Particularly, AgentCore Runtime supplies a safe, serverless, and purpose-built internet hosting setting for deploying and working AI brokers or instruments. AgentCore Runtime is framework agnostic, working seamlessly with widespread frameworks like LangGraph, Strands, and CrewAI for deploying your AI brokers and instruments with automated scaling and built-in safety.
On this submit, we show the right way to use a GitHub Actions workflow to automate the deployment of AI brokers on AgentCore Runtime. This method delivers a scalable resolution with enterprise-level safety controls, offering full steady integration and supply (CI/CD) automation. By implementing a complete pipeline, we allow seamless agent deployment with AWS finest practices, together with OpenID Join (OIDC) authentication, least-privilege entry controls, and setting separation. Our resolution facilitates environment friendly updates for present brokers and integrates steady safety scans and rigorous code high quality checks. The outcome is a sturdy deployment technique that helps reduce operational complexity, improve safety, and speed up AI agent improvement throughout enterprise environments.
Advantages of Amazon Bedrock AgentCore Runtime
AgentCore Runtime is the best service for manufacturing agent deployments:
- Gives a framework agnostic setting to run your brokers
- Works with massive language fashions (LLMs) equivalent to fashions provided by Amazon Bedrock and Anthropic Claude
- Gives session isolation by working every consumer session in a devoted microVM with remoted CPU, reminiscence, and file system sources
- Helps each real-time interactions and long-running workloads as much as 8 hours
- Gives built-in capabilities for authentication and observability
Resolution overview
We’ve developed a complete CI/CD pipeline with GitHub Actions that streamlines the deployment of Brokers in compliance with safety normal. The pipeline is obtainable as a ready-to-use resolution that may combine seamlessly together with your present improvement workflow.The answer consists of the next key elements:
The next diagram illustrates the structure for the answer.
The info circulation consists of the next steps:
- A developer commits code modifications from their native repository to the GitHub repository. On this resolution, the GitHub Motion is triggered manually, however this may be automated.
- The GitHub Motion triggers the construct stage.
- GitHub’s OIDC makes use of tokens to authenticate with AWS and entry sources.
- GitHub Actions invokes the command to construct and push the agent container picture to Amazon ECR instantly from the Dockerfile.
- AWS Inspector triggers a complicated safety scan when the picture is uploaded.
- An AgentCore Runtime occasion is created utilizing the container picture.
- The agent can additional question the Amazon Bedrock mannequin and invoke instruments in line with its configuration.
Within the following sections, we stroll by means of the steps to deploy the answer:
- Obtain the supply code from the GitHub repo.
- Create your agent code.
- Arrange GitHub secrets and techniques.
- Create an IAM function and insurance policies.
- Create the GitHub Actions workflow.
- Set off and monitor the pipeline.
- Confirm the deployment.
Conditions
Earlier than you should utilize our safe CI/CD pipeline for deploying brokers to AgentCore Runtime, confirm you’ve gotten the next conditions in place:
Obtain supply code
Clone the supply code repository: bedrock-agentcore-runtime-cicd
git clone https://github.com/aws-samples/sample-bedrock-agentcore-runtime-cicd.git
The repository folder consists of the next construction:
Create agent code
Create your agent with the framework of your alternative utilizing the AgentCore Runtime toolkit. The toolkit makes use of BedrockAgentCoreApp to create an software that gives a standardized option to package deal your AI agent code right into a container that may run on AgentCore Runtime managed infrastructure. It additionally makes use of app.entrypoint, a Python decorator that marks a perform as the primary entry level. When the Amazon Bedrock agent receives the incoming API request, this perform receives and processes the consumer’s request. On this pattern agent code, when somebody calls your Amazon Bedrock agent utilizing an API, AgentCore Runtime will robotically name the strands_agent_bedrock(payload) perform.
On this submit, we use the brokers/strands_agent.py file to create an agent utilizing the Strands Brokers framework:
Arrange GitHub secrets and techniques
The GitHub Actions workflow should entry sources in your AWS account. On this submit, we use an IAM OpenID Join id supplier and IAM roles with IAM insurance policies to entry AWS sources. OIDC lets your GitHub Actions workflows entry sources in AWS while not having to retailer the AWS credentials as long-lived GitHub secrets and techniques. These credentials are saved as GitHub secrets and techniques inside your GitHub repository Settings below Secrets and techniques possibility. For extra data, see Using secrets in GitHub Actions.
Create IAM roles and insurance policies
To run brokers or instruments in AgentCore Runtime, you want an IAM execution function. For details about creating an IAM function, see IAM role creation.
On this submit, we create the required belief coverage and execution function for AgentCore Runtime. See IAM Permissions for AgentCore Runtime for extra particulars.
The next code is for the AgentCore Runtime belief coverage:
The next code is for the AgentCore Runtime execution function:
Create the GitHub Actions workflow
Refer the CI/CD workflow file at .github/workflows/deploy-agentcore.yml for particulars to create the workflow.The next steps will likely be carried out by the workflow:
- It makes use of the default Ubuntu Github Runner for the duty supplied within the pipeline.
- The workflow installs the required dependencies talked about within the
requirement.txtfile. - It builds the Docker picture and deploys it on the ECR repository.
- The picture is scanned with Amazon Inspector to determine potential vulnerabilities.
- AgentCore Runtime deploys the agent as an endpoint.
- The workflow assessments the agent endpoint to confirm performance.
Set off and monitor pipeline
This pipeline could be triggered both by altering a code within the brokers folder or manually utilizing the workflow dispatch possibility. This may additional change in line with your group’s branching technique. Replace the code in .github/workflows/deploy-agentcore.yml to vary this set off conduct.
Check agent
After the agent is deployed, we’ll confirm its performance by triggering the Check Agent workflow manually by way of workflow dispatch possibility.
AgentCore Runtime versioning and endpoints
Amazon Bedrock AgentCore implements automated versioning for AgentCore Runtime and allows you to handle completely different configurations utilizing endpoints. Endpoints present a option to reference particular variations of AgentCore Runtime. For extra particulars and pattern code, see AgentCore Runtime versioning and endpoints.
Clear up
To keep away from incurring future expenses, full the next steps:
- Delete the ECR pictures from the Amazon ECR console created by means of the deployment utilizing GitHub Actions.
- Delete the agent deployed in AgentCore Runtime.
Conclusion
On this submit, we demonstrated a complete method to utilizing GitHub Actions for a safer and scalable deployment of AI brokers on AgentCore Runtime. Our resolution supplies a sturdy, automated, and managed setting for generative AI functions, addressing essential enterprise deployment challenges by automating dependency administration, implementing steady code high quality checks, performing complete vulnerability scanning, and facilitating constant deployment processes. By abstracting infrastructure complexities, this pipeline helps builders deal with agent logic and performance, whereas offering a framework-agnostic method that helps seamless administration of a number of AI brokers at scale. As AI brokers proceed to rework enterprise capabilities, this resolution represents a major step in direction of streamlining AI agent improvement and operational administration, providing a standardized, safe, and environment friendly deployment mechanism for contemporary generative AI functions.
As a subsequent step, you should utilize Amazon Q to intelligently improve and customise your AI agent deployment pipeline, remodeling your CI/CD processes with superior, context-aware automation.
Concerning the authors
Prafful Gupta is an Assoc. Supply Guide at AWS based mostly in Gurugram, India. Having began his skilled journey with Amazon a yr in the past, he makes a speciality of DevOps and Generative AI options, serving to prospects navigate their cloud transformation journeys. Past work, he enjoys networking with fellow professionals and spending high quality time with household. Join on LinkedIn at: linkedin.com/in/praffulgupta11/
Anshu Bathla is a Lead Guide – SRC at AWS, based mostly in Gurugram, India. He works with prospects throughout various verticals to assist strengthen their safety infrastructure and obtain their safety targets. Exterior of labor, Anshu enjoys studying books and gardening at his house backyard. Join on LinkedIn at: linkedin.com/in/anshu-bathla/




