![[Report] I Learned How to Protect Resources Outside the VPC with a Network Perimeter #AWSreInvent #SEC340](https://devio2024-media.developers.io/image/upload/f_auto,q_auto/c_limit,w_1200/v1796065673/eyecatch/xw5jr5b9agc6qjxlknmg.png)
[Report] I Learned How to Protect Resources Outside the VPC with a Network Perimeter #AWSreInvent #SEC340
This page has been translated by machine translation. View original
Introduction
Hello everyone, this is Akaike.
I'm attending AWS re:Invent 2026, and I listened to a Lightning talk session called "Good fences make good neighbors: a network perimeter approach to data perimeters".
S3 and SQS are resources that are placed outside the VPC, so security groups and route tables alone can't create a state where "access is possible only from your own network"...
This session explained how to combine data perimeters built with IAM policies with network controls using DNS Firewall and Network Firewall, so I've summarized the content.
Session Overview
Title
Good fences make good neighbors: a network perimeter approach to data perimeters (SEC340)
Abstract
How do you secure that which has no network? AWS services such as S3, SQS, and DynamoDB help teams build and scale faster but come with a different set of security implications than services that live in your VPC. In this session, you'll learn about best practices and architectural patterns for building secure networks on AWS using network features like DNS firewall, and Network firewall and layering them with AWS IAM policies like VPC endpoint policy, and Resource Control Policy to help ensure that your resources that live outside of your network behave like they are in your network.
Speakers
- Bryan Van Hook
- Jesse Lepich (Sr. Solutions Architect, AWS)
Session Information
- Level: 300 - Advanced
- Session type: Lightning talk
- Topic: Security & Identity
- Related services
- AWS Identity and Access Management (IAM)
- Amazon Virtual Private Cloud (Amazon VPC)

Session Content
Agenda

The session was structured as follows.
- Data perimeters: setting the boundary
- Threat vectors and risk landscape
- Deep dive: network perimeter
- Layering network controls
- Best practices
The session was broadly divided into two parts.
In the first half, Bryan Van Hook explained data perimeters and network perimeters built with IAM policies.
In the second half, Jesse Lepich explained how to restrict outbound traffic with DNS Firewall and Network Firewall.
First Half: Data Perimeters and Network Perimeters Built with IAM Policies
What is a data perimeter?

A data perimeter is a set of permission guardrails that ensure only your own identities can access your own resources, and only from your own networks.
The target network can be either inside or outside AWS.
- Things that belong to me
- Your on-premises data centers
- Your company's AWS accounts and their VPCs
- Things that do not belong to me
- AWS accounts outside your company
- The rest of the internet
As examples of each, the resource is an S3 bucket, the identity is an IAM role, and the network is the VPC of your company's AWS account or a trusted network outside AWS.
Data perimeter objectives

A data perimeter has three objectives.
The first is the Resource Perimeter, which ensures that your identities can access only trusted resources.
The diagram above shows an example where an internal threat actor in the corporate data center tries to access an S3 bucket in an external account using legitimate corporate credentials.

The second is the Network Perimeter, which prevents threat actors from accessing resources from networks that aren't yours.
The diagram above showed an example where an external threat actor tries to access your company's S3 bucket with illegitimately obtained credentials.

The third is the Identity Perimeter, which ensures that only trusted identities can operate within your environment.
The diagram above showed an example where an internal threat actor inside the VPC tries to access an external S3 bucket using personal credentials brought in from outside.
Network perimeter objectives

This session took a deep dive into the network perimeter among the three.
The network perimeter has the following two objectives.
- My resources can only be accessed from expected networks
(My resources can be accessed only from the networks I expect) - My identities can access resources only from expected networks
(My identities can access resources only from the networks I expect)
The diagram above showed employees in the corporate data center being able to access the S3 bucket, while employees at an external location cannot.
In other words, the goal is a state where, even with legitimate credentials, access is impossible unless it comes from a trusted network.
Amazon S3 is not in your VPC

What you need to remember when building a data perimeter for S3 is that S3 itself doesn't run inside your VPC.
When you resolve the S3 domain, you get back a public IP that isn't included in the VPC CIDR (172.31.0.0/16).
$ dig +short s3.us-east-2.amazonaws.com
52.219.101.97

Therefore, you would normally access S3's public IP through a NAT gateway and an Internet gateway.
What does "S3 in my VPC" mean exactly?
The session then explained, from three perspectives, what it means for S3 to be logically inside the VPC.

"“S3 in my VPC” = reaching S3 does not require a route to the internet"
(S3 being in my VPC means that reaching S3 does not require a route to the internet)
If you enable private access to S3 without going through the internet, you've extended the VPC boundary around S3.

"“S3 in my VPC” = ability to block access originating from outside the VPC"
(S3 being in my VPC means being able to block access originating from outside the VPC)

"“S3 in my VPC” = ability to block access originating from this VPC to unexpected destinations"
(S3 being in my VPC means being able to block access from this VPC to unexpected destinations)
In other words, you also need to prevent resources and identities inside the VPC from accessing other S3 buckets that aren't yours.
The real power of VPC endpoints: Authorization

VPC endpoints make this possible.
When you create a VPC endpoint for S3 in your VPC, you can communicate with S3 without going through the internet.
More importantly, requests that pass through a VPC endpoint have the aws:SourceVpc and aws:SourceVpce condition keys set.
Using these, you can, for example, make an S3 bucket readable only by requests from a VPC you manage.
This is an example of an S3 bucket policy that blocks reads from unexpected networks.
{
"Sid": "RequireExpectedNetworks",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::this-bucket/*",
"Condition": {
"StringNotEqualsIfExists": {
"aws:SourceVpc": "vpc-11112222"
}
}
}

The same condition can be used on the identity side as well.
If you put the following condition in an IAM role's policy, that role's credentials can use AWS services only from within the VPC.
Even if the credentials are taken out and used somewhere else, access isn't possible.
{
"Sid": "RequireExpectedNetworks",
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": {
"aws:SourceVpc": "vpc-11112222"
}
}
}
Note that if you use this example as is, cases where an AWS service accesses resources on your behalf using the caller's credentials (FAS, described later) will also be denied.
In actual use, you'll also need exception conditions such as aws:ViaAWSService, which is introduced later in "Network perimeter – with service access".

"The VPC endpoint policy is a boundary: grants no access; must be satisfied for the request to succeed"
(The VPC endpoint policy is a boundary: it grants no access, and it must be satisfied for the request to succeed)
With a VPC endpoint policy, you can allow only requests from identities that belong to your own AWS Organizations organization.
You specify the organization ID with aws:PrincipalOrgId, so there's no need to enumerate account numbers or role names, which makes it a method that scales easily, we were told.
{
"Sid": "RequireTrustedIdentities",
"Effect": "Allow",
"Principal": "*",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgId": "o-a1b2c3"
}
}
}
Network perimeter – control 1

Next up was Resource Control Policies (RCPs).
An RCP is a policy similar to a Service Control Policy (SCP). While SCPs restrict the permissions of principals, RCPs centrally restrict access to resources in the organization.
The following example denies all requests to S3 in the organization that come neither from the corporate IP address range nor through a VPC endpoint owned by your organization.
{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"NotIpAddressIfExists": {
"aws:SourceIp": "<my-corporate-cidr>"
},
"StringNotEqualsIfExists": {
"aws:VpceOrgId": "<my-org-id>"
}
}
}
aws:SourceIp: The corporate IP address range (My corporate IP space)aws:VpceOrgId: VPC endpoints owned by my organization (My AWS network)
Incidentally, the IAM documentation explains that this condition key (written as aws:VpceOrgID in the documentation) can automatically include all VPC endpoints owned by accounts in the organization, so it lets you configure the network perimeter in the most scalable way.
As the note on the slide also indicated, the services that support RCPs are limited.
You can check the supported services in the AWS Organizations documentation.
Network perimeter – service access
Here, we need to consider the case where an AWS service accesses resources on your behalf.
There are three ways this happens.

The first is Forward access sessions (FAS).
For example, when you run a query in Amazon Athena, Athena writes the results to an S3 bucket in your account.
In this case, Athena isn't assuming a role, but is using the caller's session to operate on your behalf.

The second is a service principal.
For example, AWS CloudTrail writes logs to an S3 bucket you manage.
In this case, you simply allow writes from cloudtrail.amazonaws.com in the bucket policy, and no role is involved.

The third is a service-linked role (SLR).
It's a role that an AWS service creates in your account, and the service assumes this role to operate on resources in the account.
The example above was AWSServiceRoleForAccessAnalyzer of AWS IAM Access Analyzer.
Network perimeter – with service access

Taking these three into account, the following example adds the aws:PrincipalIsAWSService and aws:ViaAWSService conditions to the previous RCP.
{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"NotIpAddressIfExists": {
"aws:SourceIp": "<my-corporate-cidr>"
},
"StringNotEqualsIfExists": {
"aws:VpceOrgId": "<my-org-id>"
},
"BoolIfExists": {
"aws:PrincipalIsAWSService": "false",
"aws:ViaAWSService": "false"
}
}
}
aws:PrincipalIsAWSService: Requests from an AWS service principal (AWS service principal)aws:ViaAWSService: Requests from an AWS service that use the caller's identity (FAS)
Note that RCPs don't apply to SLRs.
Network perimeter – with aws:SourceVpc

The last example introduced used aws:SourceVpc.
The RCP on the left uses aws:SourceVpc instead of aws:VpceOrgId, and denies, across the whole organization, access to SQS that comes from neither the corporate IP address range nor a specific VPC.
{
"Effect": "Deny",
"Principal": "*",
"Action": "sqs:*",
"Resource": "*",
"Condition": {
"NotIpAddressIfExists": {
"aws:SourceIp": "<my-corporate-cidr>"
},
"StringNotEqualsIfExists": {
"aws:SourceVpc": "<my-vpc>"
},
"BoolIfExists": {
"aws:PrincipalIsAWSService": "false",
"aws:ViaAWSService": "false"
}
}
}
The one on the right is an SCP example that prevents a VPC in one Region from accessing AWS services in another Region.
Using this, you can keep all access from the VPC to AWS within the same Region.
{
"Sid": "SourceVPCRegion",
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:SourceVpc": "<my-vpc-in-this-region>"
},
"StringNotEqualsIfExists": {
"aws:RequestedRegion": "<my-vpc-region>"
}
}
}
Second Half: Restricting Outbound Traffic with DNS Firewall and Network Firewall
Formal Egress Security Guidance

The first half covered identity-side controls, a way to apply least privilege to access to resources.
However, many customers want to apply least privilege to the whole network, including traffic going out to the internet.
If you want to build a completely isolated environment, you need to combine data perimeter controls with network controls.
The slide quoted CISA's red team guidance.
It is said to be a recommendation based on red team exercises CISA conducted at many government agencies.
"Configure internal firewalls and proxies to restrict internet traffic from hosts that do not require it. If a host requires specific outbound traffic, consider creating an allowlist policy of domains."
(Restrict traffic with internal firewalls and proxies for hosts that don't need internet communication. For hosts that need specific outbound traffic, consider creating an allowlist of domains)
Typical web app architecture – Ingress & Egress

In a typical web application architecture, there are two paths going out.
- The path through a NAT gateway and an Internet gateway
- The DNS path where Route 53 Resolver performs recursive name resolution
Even when a customer says, "We don't use the internet at all. We have no NAT gateway or Internet gateway, just an isolated setup with only VPC endpoints," a closer look often reveals that a route to on-premises or the internet remains somewhere.
Both of these paths could be used by threat actors.

So, we place DNS Firewall and Network Firewall on these two paths.
Both can apply domain-based rules at the network layer, so you can narrow down tightly the destinations a workload is allowed to reach.
The two are separate services, but they now work closely together in terms of functionality, and threat information can be shared between them, we were told.
One interesting point was that there are many cases where customers who thought "we use VPC endpoints, so we don't need much control on this path" found, once they actually deployed these, that they weren't using VPC endpoints as much as they thought.
DNS Firewall and Network Firewall are also useful as places to verify that VPC endpoints are really being used.
Furthermore, by adding a simple rule on this path that blocks AWS service domains, you can also force traffic onto VPC endpoints.
Three different models

Three typical models were introduced as ways to move the network toward least privilege.
Basically, you proceed from left to right.
| Model | Description | Estimated time |
|---|---|---|
| Deny list | Allow everything and block only known malicious domains | Hours |
| Generous allow list + Deny list | Allow categories of trusted domains, use a deny list alongside, and deny everything else | Days |
| Strict allow list | Allow only a strictly defined list of domains | Weeks? |
The slide compared with bars how, as you move to the right-hand models, the implementation effort increases and the risk reduction also grows.
Deny list
DNS Firewall and Network Firewall have lists of malicious domains that you don't want your resources to access, such as domains used for C2 (command and control).
In addition to AWS's internal threat intelligence, information from partners such as Infoblox and Palo Alto can also be used, we were told.
You just specify the list of malicious domains, so it's easy to adopt.
The typical approach is to first leave things allowed and only collect logs, confirm that legitimate traffic isn't being blocked, and then quickly switch to blocking.
The partner information is provided as DNS Firewall Advanced rules.
The documentation introduces the managed protections of Palo Alto Networks Advanced DNS Security and Infoblox as requiring a subscription through AWS Marketplace.
Generous allow list
Customers interested in data perimeters often want to go a step further and aim for an environment where only what they want to happen happens.
The first step toward that is the Generous allow list, where you put sets or categories of domains, or specific subdomains and root domains, in an allow list and block everything else.
It takes more effort than a deny list, but because you go from a state with no restrictions on destinations to a relatively narrow range of allowed destinations, you can greatly reduce risk.
How generous to be differs by customer, and the thinking also differs between a PCI environment and a general production environment.
Using the categories and top-level domains in DNS Firewall and Network Firewall makes it easier to build, we were told.
From a security perspective you might feel resistance, thinking "all sorts of things can still happen within that range", but the explanation was that it's far better than a state where anything other than what the deny list denies can happen.
Strict allow list
Customers who want to go further identify all the fully qualified domain names that appear in the logs and create a Strict allow list that permits only the domains they've reviewed.
The risk reduction is large, but you need to think about how to manage the allow list over the long term while watching the logs, and it also takes effort.
The two allow list models also have the advantage of making it easier to understand what a workload is doing.
You can pass logs to the security operations center (SOC) for threat hunting, or do profiling such as seeing that only specific instances are being blocked.
These are things that weren't possible with a deny list alone.
Time Invested vs. Risk Reduced

This slide organizes how much risk you can reduce relative to the time invested into four stages.
- Deny Lists Managed Rules
- Block known malicious domains with the managed rules of DNS Firewall and Network Firewall. The best place to start
- Deny Lists Custom Rules
- Block high-risk top-level domains such as
.infoand.zipwith custom rules. Confirm that the traffic isn't legitimate, or set up exceptions
- Block high-risk top-level domains such as
- Generous Allow-List
- The sweet spot for many customers
- Strict Allow-List
- The stage aimed at by customers who want to go further
What was emphasized is not to skip the first three.
If you start with a Strict allow list right away, long-term management becomes difficult.
If you block legitimate application traffic at the start of a project, the team managing the firewall ends up having to explain themselves and has to regain the trust needed to move on to the next stage, we were told.
Automatic Creation of DNS Firewall Allow Lists

Finally, DNS Firewall's Automated Allowlists was introduced as a new feature that helps with creating allow lists.
- When creating an allow list rule, you specify the period to analyze. The maximum is the past 7 days
- After analyzing for a while depending on the size of your environment, the observed domains are displayed on a dashboard
- For each observed domain, you can choose to add it to the allow list or reject it
- You can also edit domains, for example by using wildcards within a safe range
- When changes in the application require a new destination, it shows up as an observed domain, so you can make a decision from there
In the console in the photo, the analysis period was 7 days, Allowed domains was 13, Observed domains was 37, and Rejected domains was 1.
According to What's New, this feature was announced on 2026/11/17, and the analysis period can be set in a range from 1 hour to 7 days.
You can also deploy it across multiple VPCs and accounts using AWS Firewall Manager or Route 53 Profiles.
DNS Firewall Advanced users can use it at no additional charge.
Note that it isn't available in AWS GovCloud (US) and the China Regions.
Conclusion
That was my report on the session "Good fences make good neighbors: a network perimeter approach to data perimeters".
The first half covered data perimeters through IAM policies, and the second half covered DNS and network controls. Even as a 20-minute Lightning talk, it was a session that organized "how to protect resources outside the VPC" from both sides.
Personally, the following points were especially impressive.
- Organizing "S3 is in the VPC" into three states
- It was easy to understand that a boundary exists only when you stop not only internet traversal, but also both inbound access from outside and outbound access from inside to unexpected destinations
- Distinguishing the three ways AWS services access on your behalf
- FAS, service principals, and SLRs handle exceptions differently, so it seems I won't get lost when writing RCPs
- DNS Firewall being useful for checking whether VPC endpoints are really being used
- I was told that even when you think you've isolated things, another path often remains, so I'd like to check my own environment too
- Not aiming for a Strict allow list right away
- I strongly agreed with the organizational reason that if you stop legitimate traffic, the firewall team loses trust
First, in my own test environment, I'd like to look at the domains observed by DNS Firewall's Automated Allowlists and think about how far to allow if I were to build a Generous allow list.
