When deploying AI brokers to Amazon Bedrock AgentCore Runtime (at the moment in preview), clients typically wish to use {custom} domains to create an expert and seamless expertise.
By default, AgentCore Runtime brokers use endpoints like https://bedrock-agentcore.{area}.amazonaws.com/runtimes/{EncodedAgentARN}/invocations.
On this publish, we focus on tips on how to rework 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 Certificates Supervisor (ACM) to create a safe, scalable {custom} area setup that works seamlessly along with your current brokers.
Advantages of Amazon Bedrock AgentCore Runtime
When you’re constructing AI brokers, you might have in all probability wrestled with internet hosting challenges: managing infrastructure, dealing with authentication, scaling, and sustaining safety. Amazon Bedrock AgentCore Runtime helps deal with these issues.
Amazon Bedrock AgentCore Runtime is framework agnostic; you should use it with LangGraph, CrewAI, Strands Brokers, or {custom} brokers you might have constructed from scratch. It helps prolonged execution occasions as much as 8 hours, excellent for advanced 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 functions.
The consumption-based pricing mannequin means you solely pay for what you employ, not what you provision. And in contrast to different internet hosting options, Amazon Bedrock AgentCore Runtime consists of 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 functions make direct HTTPS requests to the service endpoint. Though this works, {custom} domains provide a number of advantages:
- Customized branding – Consumer-side functions (internet browsers, cell apps) show your branded area as an alternative of AWS infrastructure particulars in community requests
- Higher developer expertise – Growth groups can use memorable, branded endpoints as an alternative of copying and pasting lengthy AWS endpoints throughout code bases and configurations
- Simplified upkeep – Customized domains make it simple to handle endpoints when deploying a number of brokers or updating configurations throughout environments
Answer 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 an alternative of utilizing the default endpoint, your functions 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 shopper utility authenticates with Amazon Cognito and receives a bearer token.
- The shopper 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 the identical path.
You should utilize the identical CloudFront distribution to serve each your frontend utility and backend agent endpoints, avoiding cross-origin useful resource sharing (CORS) points as a result of all the things originates from the identical area.
Conditions
To observe this walkthrough, you should have the next in place:
Though Amazon Bedrock AgentCore Runtime will be in different supported AWS Areas, CloudFront requires SSL certificates to be within the us-east-1 Area.
You’ll be able to 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 in the event you don’t have one
- Use the default URL from CloudFront – No area registration or configuration required
Select the third choice if you wish to check the answer rapidly earlier than establishing a {custom} area.
Create an agent with inbound authentication
If you have already got an agent deployed with OAuth authentication, you may skip to the following part to arrange the {custom} area. In any other case, observe these steps to create a brand new agent utilizing Amazon Cognito as your OAuth supplier:
- Create a brand new listing to 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 check person:
- Deploy the agent utilizing the Amazon Bedrock AgentCore command line interface (CLI) offered by the starter toolkit:
Make word of your agent runtime Amazon Useful resource Title (ARN) after deployment. You will want this for the {custom} area configuration.
For added 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 tips on how 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 venture:
- Encode the agent ARN and put together the CloudFront origin configuration:
In case your frontend utility runs on a special area than your agent endpoint, you should configure CORS headers. That is frequent in case your frontend is hosted on a special area (for instance, https://app.yourcompany.com calling https://agent.yourcompany.com), or in the event you’re creating regionally (for instance, http://localhost:3000 calling your manufacturing agent endpoint).
- To deal with CORS necessities, create a CloudFront response headers coverage:
- Create a CloudFront distribution to behave as a reverse proxy to your agent endpoints:
Set cache_policy=CachePolicy.CACHING_DISABLED to verify your agent responses stay dynamic and aren’t cached by CloudFront.
- When you’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 may 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 title (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 may check 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:
Issues
As you implement this resolution in manufacturing, the next are some essential concerns:
- Price implications – CloudFront provides prices for knowledge switch and requests. Evaluate Amazon CloudFront pricing to grasp the affect to your utilization patterns.
- Safety enhancements – Take into account implementing the next safety measures:
- AWS WAF guidelines to assist shield in opposition to frequent internet exploits.
- Charge limiting to assist stop abuse.
- Geo-restrictions in case your agent ought to solely be accessible from particular Areas.
- Monitoring – Allow CloudFront entry logs and arrange Amazon CloudWatch alarms to observe error charges, latency, and request quantity.
Clear up
To keep away from ongoing prices, delete the assets if you not want them:
You may have to manually delete the Route 53 hosted zones and ACM certificates from their respective service consoles.
Conclusion
On this publish, we confirmed you tips on how to create {custom} domains to your Amazon Bedrock AgentCore Runtime agent endpoints utilizing CloudFront as a reverse proxy. This resolution supplies a number of key advantages: simplified integration for improvement groups, {custom} domains that align along with your group, cleaner infrastructure abstraction, and simple upkeep when endpoints want updates. By utilizing CloudFront as a reverse proxy, you can even serve each your frontend utility and backend agent endpoints from the identical area, avoiding frequent CORS challenges.
We encourage you to discover this resolution additional by adapting it to your particular wants. You may wish to improve it with extra safety features, arrange monitoring, or combine it along with your current infrastructure.
To study extra about constructing and deploying AI brokers, see the Amazon Bedrock AgentCore Developer Information. For superior configurations and finest practices with CloudFront, consult with the Amazon CloudFront documentation. You could find detailed details about SSL certificates within the AWS Certificates Supervisor documentation, and area administration within the Amazon Route 53 documentation.
Amazon Bedrock AgentCore is at the moment in preview and topic to vary. Normal AWS pricing applies to extra providers used, equivalent to CloudFront, Route 53, and Certificates Supervisor.
Concerning the authors
Rahmat Fedayizada is a Senior Options Architect with the AWS Vitality and Utilities staff. He works with power firms to design and implement scalable, safe, and extremely out there architectures. Rahmat is enthusiastic about translating advanced 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 staff of resolution architects serving to power clients innovate and speed up their transformation. Having began as a Answer Architect in 2012, Paras is enthusiastic about architecting scalable options and constructing organizations centered on utility modernization and AI initiatives.

