Arrange {custom} domains for Amazon Bedrock AgentCore Runtime brokers
When deploying AI agents to Amazon Bedrock AgentCore Runtime (at present in preview), clients typically need to use {custom} domains to create knowledgeable and seamless expertise.
By default, AgentCore Runtime brokers use endpoints like https://bedrock-agentcore.{area}.amazonaws.com/runtimes/{EncodedAgentARN}/invocations.
On this submit, we talk about easy methods to remodel these endpoints into user-friendly {custom} domains (like https://agent.yourcompany.com) utilizing Amazon CloudFront as a reverse proxy. The answer combines CloudFront, Amazon Route 53, and AWS Certificate Manager (ACM) to create a safe, scalable {custom} area setup that works seamlessly along with your current brokers.
Advantages of Amazon Bedrock AgentCore Runtime
If you happen to’re constructing AI brokers, you’ve gotten most likely wrestled with internet hosting challenges: managing infrastructure, dealing with authentication, scaling, and sustaining safety. Amazon Bedrock AgentCore Runtime helps handle these issues.
Amazon Bedrock AgentCore Runtime is framework agnostic; you need to use it with LangGraph, CrewAI, Strands Agents, or {custom} brokers you’ve gotten constructed from scratch. It helps prolonged execution instances as much as 8 hours, good for complicated reasoning duties that conventional serverless capabilities can’t deal with. Every person session runs in its personal remoted microVM, offering safety that’s essential for enterprise purposes.
The consumption-based pricing mannequin means you solely pay for what you utilize, not what you provision. And in contrast to different internet hosting options, Amazon Bedrock AgentCore Runtime contains built-in authentication and specialised observability for AI brokers out of the field.
Advantages of {custom} domains
When utilizing Amazon Bedrock AgentCore Runtime with Open Authorization (OAuth) authentication, your purposes make direct HTTPS requests to the service endpoint. Though this works, {custom} domains provide a number of advantages:
- Customized branding – Consumer-side purposes (internet browsers, cell apps) show your branded area as a substitute of AWS infrastructure particulars in community requests
- Higher developer expertise – Improvement groups can use memorable, branded endpoints as a substitute of copying and pasting lengthy AWS endpoints throughout code bases and configurations
- Simplified upkeep – Customized domains make it easy to handle endpoints when deploying a number of brokers or updating configurations throughout environments
Resolution overview
On this resolution, we use CloudFront as a reverse proxy to rework requests out of your {custom} area into Amazon Bedrock AgentCore Runtime API calls. As a substitute of utilizing the default endpoint, your purposes could make requests to a user-friendly URL like https://agent.yourcompany.com/.
The next diagram illustrates the answer structure.

The workflow consists of the next steps:
- A consumer software authenticates with Amazon Cognito and receives a bearer token.
- The consumer makes an HTTPS request to your {custom} area.
- Route 53 resolves the DNS request to CloudFront.
- CloudFront forwards the authenticated request to the Amazon Bedrock Runtime agent.
- The agent processes the request and returns the response by means of the identical path.
You need to use the identical CloudFront distribution to serve each your frontend software and backend agent endpoints, avoiding cross-origin resource sharing (CORS) points as a result of every thing originates from the identical area.
Stipulations
To comply with this walkthrough, you have to have the next in place:
Though Amazon Bedrock AgentCore Runtime might be in different supported AWS Regions, CloudFront requires SSL certificates to be within the us-east-1 Area.
You may select from the next area choices:
- Use an current area – Add a subdomain like
agent.yourcompany.com - Register a brand new area – Use Route 53 to register a site should you don’t have one
- Use the default URL from CloudFront – No area registration or configuration required
Select the third possibility if you wish to take a look at the answer shortly earlier than organising a {custom} area.
Create an agent with inbound authentication
If you have already got an agent deployed with OAuth authentication, you possibly can skip to the subsequent part to arrange the {custom} area. In any other case, comply with these steps to create a brand new agent utilizing Amazon Cognito as your OAuth supplier:
- Create a brand new listing on your agent with the next construction:
- Create the primary agent code in
agent_example.py:
- Add dependencies to
necessities.txt:
- Run the next instructions to create an Amazon Cognito person pool and take a look at person:
- Deploy the agent utilizing the Amazon Bedrock AgentCore command line interface (CLI) supplied by the starter toolkit:
Make word of your agent runtime Amazon Useful resource Title (ARN) after deployment. You’ll need this for the {custom} area configuration.
For extra examples and particulars, see Authenticate and authorize with Inbound Auth and Outbound Auth.
Arrange the {custom} area resolution
Now let’s implement the {custom} area resolution utilizing the AWS CDK. This part exhibits you easy methods to create the CloudFront distribution that proxies your {custom} area requests to Amazon Bedrock AgentCore Runtime endpoints.
- Create a brand new listing and initialize an AWS CDK mission:
- Encode the agent ARN and put together the CloudFront origin configuration:
In case your frontend software runs on a unique area than your agent endpoint, you have to configure CORS headers. That is widespread in case your frontend is hosted on a unique area (for instance, https://app.yourcompany.com calling https://agent.yourcompany.com), or should you’re creating domestically (for instance, http://localhost:3000 calling your manufacturing agent endpoint).
- To deal with CORS necessities, create a CloudFront response headers policy:
- Create a CloudFront distribution to behave as a reverse proxy on your agent endpoints:
Set cache_policy=CachePolicy.CACHING_DISABLED to ensure your agent responses stay dynamic and aren’t cached by CloudFront.
- If you happen to’re utilizing a {custom} area, add an SSL certificates and DNS configuration to your stack:
The next code is the whole AWS CDK stack that mixes all of the elements:
- Configure the AWS CDK
appentry level:
Deploy your {custom} area
Now you possibly can deploy the answer and confirm it really works with each {custom} and default domains. Full the next steps:
- Replace the next values in
agentcore_custom_domain_stack.py:- Your Amazon Bedrock AgentCore Runtime ARN
- Your area identify (if utilizing a {custom} area)
- Your hosted zone ID (if utilizing a {custom} area)
- Deploy utilizing the AWS CDK:
Check your endpoint
After you deploy the {custom} area, you possibly can take a look at your endpoints utilizing both the {custom} area or the CloudFront default area.First, get a JWT token from Amazon Cognito:
Use the next code to check along with your {custom} area:
Alternatively, use the next code to check with the CloudFront default area:
Concerns
As you implement this resolution in manufacturing, the next are some necessary concerns:
- Value implications – CloudFront provides prices for information switch and requests. Assessment Amazon CloudFront pricing to know the influence on your utilization patterns.
- Safety enhancements – Think about implementing the next safety measures:
- AWS WAF guidelines to assist defend towards widespread internet exploits.
- Fee limiting to assist forestall abuse.
- Geo-restrictions in case your agent ought to solely be accessible from particular Areas.
- Monitoring – Allow CloudFront access logs and arrange Amazon CloudWatch alarms to watch error charges, latency, and request quantity.
Clear up
To keep away from ongoing prices, delete the sources once you not want them:
You would possibly must manually delete the Route 53 hosted zones and ACM certificates from their respective service consoles.
Conclusion
On this submit, we confirmed you easy methods to create {custom} domains on your Amazon Bedrock AgentCore Runtime agent endpoints utilizing CloudFront as a reverse proxy. This resolution gives a number of key advantages: simplified integration for improvement groups, {custom} domains that align along with your group, cleaner infrastructure abstraction, and easy upkeep when endpoints want updates. Through the use of CloudFront as a reverse proxy, you too can serve each your frontend software and backend agent endpoints from the identical area, avoiding widespread CORS challenges.
We encourage you to discover this resolution additional by adapting it to your particular wants. You would possibly need to improve it with extra safety features, arrange monitoring, or combine it along with your current infrastructure.
To be taught extra about constructing and deploying AI brokers, see the Amazon Bedrock AgentCore Developer Guide. For superior configurations and finest practices with CloudFront, discuss with the Amazon CloudFront documentation. Yow will discover detailed details about SSL certificates within the AWS Certificate Manager documentation, and area administration within the Amazon Route 53 documentation.
Amazon Bedrock AgentCore is at present in preview and topic to vary. Normal AWS pricing applies to extra companies used, similar to CloudFront, Route 53, and Certificates Supervisor.
In regards to the authors
Rahmat Fedayizada is a Senior Options Architect with the AWS Power and Utilities crew. He works with power corporations to design and implement scalable, safe, and extremely obtainable architectures. Rahmat is keen about translating complicated technical necessities into sensible options that drive enterprise worth.
Paras Bhuva is a Senior Supervisor of Options Structure at AWS, the place he leads a crew of resolution architects serving to power clients innovate and speed up their transformation. Having began as a Resolution Architect in 2012, Paras is keen about architecting scalable options and constructing organizations centered on software modernization and AI initiatives.