
Private Amazon Bedrock Access with AWS Lambda
How I used AWS PrivateLink and a VPC endpoint to connect Lambda privately to Amazon Bedrock.
Private Amazon Bedrock Access with AWS Lambda
Introduction
I recently completed another hands-on lab on AWS Skill Builder: AWS SimuLearn: Set Up Private Access to Amazon Bedrock.
In my previous AWS labs, I explored prompt engineering, Amazon Bedrock, and AI agents. This time, I focused on something equally important: network security for generative AI applications.
The main challenge was understanding how an AWS Lambda function connected to a private subnet can securely communicate with Amazon Bedrock without sending API traffic over the public internet.
Through this lab, I explored how Amazon VPC, AWS PrivateLink, VPC endpoints, IAM, and AWS Lambda work together.
Here are my key takeaways.
1. Understanding the Business Scenario
The lab introduced a scenario involving a city bank that needed a secure architecture for accessing Amazon Bedrock.
The solution had two important requirements:
- Allow an AWS Lambda function to access a database in a private subnet.
- Allow the same Lambda function to invoke Amazon Bedrock foundation models without requiring public internet connectivity.
For organizations handling sensitive information, network isolation and controlled access are important parts of application security.
The goal was to build a private network path between the application and Amazon Bedrock.
2. Exploring the Solution Architecture
The architecture includes several important AWS components.
AWS Service | Responsibility |
|---|---|
Amazon VPC | Provides an isolated virtual network |
Private Subnet | Provides private network connectivity for application resources |
AWS Lambda | Runs application logic and invokes Bedrock models |
VPC Endpoint | Provides a private entry point to supported AWS services |
AWS PrivateLink | Enables private connectivity to Amazon Bedrock |
Amazon Bedrock | Provides access to foundation models |
Security Groups | Control permitted network traffic |
IAM | Manages permissions for AWS resources |
The high-level connection looks like this:
AWS Lambda → Interface VPC Endpoint → AWS PrivateLink → Amazon Bedrock
Meanwhile, Lambda can access the private database through the VPC network.
An important technical detail is that Lambda execution environments remain on AWS-managed infrastructure. Configuring VPC access allows the function to communicate with resources in the selected VPC through AWS-managed network interfaces.
3. Configuring AWS Lambda for VPC Access
One of the first concepts I explored was how AWS Lambda interacts with a VPC.
By default, Lambda runs in an AWS-managed network environment.
However, when an application needs to communicate with private resources such as a database, we can configure the function with:
- A VPC
- One or more subnets
- Security groups
In this lab, I worked with a Lambda function configured to access a private subnet.
This introduced an important networking concept:
A Lambda function connected to a VPC does not automatically have internet access.
If the VPC has no suitable internet route, requests to public endpoints may fail.
For applications that need private access to supported AWS services, VPC endpoints provide an alternative.
4. Creating a VPC Endpoint for Amazon Bedrock
This was one of the most interesting parts of the lab.
I configured an Interface VPC Endpoint for Amazon Bedrock Runtime.
The endpoint service name was:
com.amazonaws.us-east-1.bedrock-runtime This service enables private access to the Amazon Bedrock Runtime API in the
us-east-1 Region.An Interface VPC Endpoint creates network interfaces with private IP addresses in the selected subnets.
The application can then communicate with Amazon Bedrock through AWS PrivateLink instead of requiring an internet gateway or NAT gateway for those API requests.
I also explored the Private DNS option.
When Private DNS is enabled and correctly configured, applications can continue using the standard regional Bedrock Runtime hostname while the requests resolve to the private endpoint.
This makes private connectivity easier to integrate into existing applications.
5. Understanding VPC Endpoint Policies
Another important topic was access control.
When creating the VPC endpoint, I worked with a custom endpoint policy.
Instead of allowing unrestricted access to every Amazon Bedrock model, the policy was designed to permit specific model invocation operations.
For example, the lab used the following action:
bedrock:InvokeModel And a specific foundation model:
amazon.nova-micro-v1:0 The policy contains several key elements:
- Effect: Determines whether access is allowed or denied.
- Principal: Identifies which AWS principals the statement applies to.
- Action: Specifies the permitted operations.
- Resource: Defines which resources those operations can target.
One particularly useful lesson was understanding the meaning of
Principal: "*" .In an endpoint policy, this does not mean that everyone on the internet can access the service. It means the policy statement does not restrict access to a particular principal.
Other security controls, including IAM permissions and network connectivity, still apply.
This reinforced the importance of understanding multiple layers of access control in AWS.
6. Availability Zones and Network Resilience
The lab also introduced the relationship between VPC endpoints, subnets, and Availability Zones.
A subnet belongs to exactly one Availability Zone.
When configuring an Interface VPC Endpoint, selecting subnets in multiple Availability Zones allows AWS to create endpoint network interfaces across those AZs.
For example:
- Private Subnet A in
us-east-1a
- Private Subnet B in
us-east-1b
Using multiple AZs can improve the availability of the endpoint connection when the surrounding network and application are configured appropriately.
The DIY portion of the assignment also introduced additional challenges involving a second Availability Zone and updating model access to Amazon Nova Pro.
These objectives showed how networking decisions and access policies need to evolve as application requirements change.
7. Testing Private Connectivity
The practice lab included testing whether the Lambda function could access:
- A database within the private VPC environment.
- Amazon Bedrock through the private endpoint.
This validation was valuable because configuring a VPC endpoint is only one part of making the architecture work.
Successful connectivity also depends on:
- Correct VPC and subnet configuration.
- Security group rules.
- DNS resolution.
- Endpoint policies.
- IAM permissions.
If one of these components is misconfigured, the request can fail even when the other components are correct.
8. Key Lessons Learned
Here are my biggest takeaways from completing this lab.
1. VPC connectivity changes Lambda networking behavior.
A Lambda function connected to a customer VPC uses that VPC's network configuration for outbound requests.
2. AWS PrivateLink enables private access to Amazon Bedrock.
With an Interface VPC Endpoint, supported Bedrock API traffic can remain on private AWS network paths without requiring public internet connectivity.
3. Subnets and Availability Zones matter.
Selecting subnets determines where endpoint network interfaces are created. Multiple AZs can improve availability.
4. Endpoint policies provide an additional security layer.
They can restrict the actions and resources accessible through a specific endpoint.
5. Security requires multiple controls working together.
Private networking is important, but IAM permissions, security groups, endpoint policies, and application-level safeguards are also necessary.
9. Final Thoughts
This lab helped me better understand the networking side of building secure generative AI applications on AWS.
Previously, my learning focused primarily on invoking foundation models and integrating AI into applications.
This time, I explored how to design a private connection between AWS Lambda and Amazon Bedrock while maintaining access to private application resources.
My biggest takeaway is:
Building a generative AI application is not only about calling an LLM. It is also about designing secure, reliable network connectivity between the application and the services it depends on.
I'm excited to continue exploring AWS networking, security, and production-ready generative AI architectures.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article