Sub topic 17
Troubleshooting with Reachability Analyzer and understanding costs
This chapter assumes you can read VPC route tables, security groups, and network ACLs. It also assumes you have built a Transit Gateway or PrivateLink setup like the ones earlier in this tutorial. You will learn a repeatable way to find why traffic fails, then learn which parts of these designs cost money.
A layered way to debug
Connectivity through a transit gateway or an endpoint service crosses many components. A packet can fail at any of them. Check them in the order the packet meets them:
- The source's security group and subnet network ACL.
- The source subnet's VPC route table.
- The transit gateway attachment and its association.
- The transit gateway route table.
- The destination attachment, subnet route table, network ACL, and security group.
- The destination application, which must listen on the port.
The return path matters as much as the forward path. A transit gateway route table needs a route to the source network too, either propagated or static.
Reachability Analyzer
Reachability Analyzer is a configuration analysis tool. You give it a source, a destination, a protocol, and optionally a port. It does not send packets. It models your configuration and reports either the hop-by-hop path or the first component that blocks traffic.
Sources and destinations can be instances, network interfaces, transit gateway attachments, VPC endpoints, internet gateways, and other resource types. Analysis works across VPCs that connect through a transit gateway, if the VPCs are in the same Region. For accounts in one AWS Organization, cross-account analysis requires the trusted access setup described in the AWS documentation.
The workflow has two steps. First you create a path, which describes what to test. Then you start an analysis of that path.
aws ec2 create-network-insights-path \
--source eni-0aaa1111bbb22222c \
--destination eni-0ddd3333eee44444f \
--protocol tcp \
--destination-port 443
aws ec2 start-network-insights-analysis \
--network-insights-path-id nip-0123456789abcdef0
aws ec2 describe-network-insights-analyses \
--network-insights-analysis-ids nia-0123456789abcdef0 \
--query 'NetworkInsightsAnalyses[0].[Status,NetworkPathFound,Explanations]'Read the result in this order:
Statusmust besucceeded. This means the analysis ran, not that traffic flows.NetworkPathFoundistruewhen the configuration allows the path.- When it is
false,Explanationsnames the blocking component, such as a security group, a network ACL, or a route table with no matching route. It also gives the resource ID.
What the analyzer cannot see
A true result does not guarantee that a connection works. The analyzer does not check these:
- A host firewall such as
iptablesor Windows Firewall. - An application that is stopped or listening on another port.
- Health of a load balancer target.
- Name resolution. A wrong DNS answer sends clients to the wrong address, and the analyzer tests only the addresses you give it.
> Use the analyzer to rule out configuration. Use Flow Logs to see what really happened on the wire.
For PrivateLink, test from a consumer instance's network interface to the interface endpoint's network interface. That checks the consumer side. The provider side behind the Network Load Balancer is a separate check, because the endpoint hides it.
VPC Flow Logs
Flow Logs record accepted and rejected traffic as metadata, not payloads. You can enable them on a VPC, subnet, or network interface. You can also enable them on a transit gateway or a transit gateway attachment, which shows traffic that crossed the hub.
aws ec2 create-flow-logs \
--resource-type VPC \
--resource-ids vpc-0aaa1111bbb22222c \
--traffic-type ALL \
--log-destination-type s3 \
--log-destination arn:aws:s3:::example-flow-logs-bucketThe default record has srcaddr, dstaddr, srcport, dstport, protocol, and action. Use action to separate two failure types:
| Observation | Likely cause |
|---|---|
| `REJECT` at the destination interface | The destination security group or network ACL denies the traffic. |
| `ACCEPT` outbound at the source, no record at the destination | A route is missing or points the wrong way, or the transit gateway has no route. |
| `ACCEPT` for the request, no reply seen at the source | The return route is missing, or a stateless network ACL blocks the ephemeral reply ports. |
| Request accepted, then connection resets | The application or host firewall closes the connection. |
Security groups are stateful, so a reply to an allowed request is allowed. Network ACLs are stateless. They need a rule for each direction.
Common failures
| Symptom | Check |
|---|---|
| New attachment cannot reach others | Is the attachment associated with a transit gateway route table? With default association disabled, nothing is associated until you do it. |
| Others cannot reach the new attachment | Is its CIDR propagated or statically added to the route tables of the other attachments? |
| Route shows as `blackhole` | A static route points at a deleted or detached attachment. Delete or repoint the route. |
| Works one way only | The return route is missing in the other VPC route table or the transit gateway route table. |
| Some Availability Zones fail | The attachment has no subnet in that zone. Traffic from a zone without an attachment subnet cannot reach the transit gateway there. |
| Endpoint connection stays `pendingAcceptance` | The provider has not run `accept-vpc-endpoint-connections`. |
| Endpoint rejected on creation | The consumer principal is not in the service's allowed principals. |
| Endpoint resolves but connections time out | The endpoint security group does not allow the client source on the service port. |
| Endpoint DNS name returns public addresses | Private DNS is not enabled, or the application uses a different hostname. |
Overlapping CIDRs, covered in an earlier chapter, appear as routes that look correct but send traffic to the wrong place. Check for overlaps before you spend time on other layers.
To inspect a table:
aws ec2 search-transit-gateway-routes \
--transit-gateway-route-table-id tgw-rtb-0123456789abcdef0 \
--filters "Name=state,Values=active,blackhole"Understanding costs
These designs charge mostly by time provisioned and by data volume. Exact prices vary by Region and change, so read the current pricing pages before you budget. The structure is stable.
| Option | Hourly charge | Data charge |
|---|---|---|
| VPC peering | None | Standard data transfer rates apply for traffic between Availability Zones or Regions. |
| Transit Gateway | Per attachment per hour | Per GB processed through the gateway, plus inter-Region transfer on peering attachments. |
| PrivateLink interface endpoint | Per endpoint per Availability Zone per hour | Per GB processed through the endpoint. |
Four points follow from this table:
- Peering is cheapest per gigabyte but does not scale in operations. The cost rises with the number of connections you manage, not with a bill line.
- Transit Gateway cost scales with attachments and traffic. Ten VPCs mean ten hourly attachment charges, and every gigabyte between them is processed once per direction through the hub. A chatty pair of VPCs can be cheaper to peer directly, and the two can coexist.
- PrivateLink cost scales with Availability Zones. An endpoint in three zones costs about three times one zone. Place endpoints only in zones where consumers run, but keep two for resilience.
- Centralized endpoints reduce hourly charges. A shared-services VPC can host AWS service endpoints for many spokes. This trades endpoint charges for transit gateway data processing, so compare both for your traffic volume.
Cross-AZ traffic adds data transfer charges in addition to the lines above. Keeping the transit gateway attachment subnet in the same zone as the busy workloads reduces that cost. Appliance mode, used for centralized inspection, can send traffic across zones on purpose.
Reachability Analyzer charges per analysis run, and Flow Logs charge for log ingestion and storage. Both are small next to a data path, but running analyses in a loop adds up. Send Flow Logs to Amazon S3 and set a lifecycle expiration, and enable transit gateway logs only while you investigate.
Exercise
An instance in VPC A cannot reach a service on port 8443 in VPC B through a transit gateway. Reachability Analyzer returns NetworkPathFound = true. Flow Logs on the VPC B network interface show no records for the request. What do you check next, and why?
Show answer
A true result means the configuration your analysis described allows the path, so the cause lies outside what the analyzer models or outside what you tested. Confirm the analysis used destination port 8443 and the right network interfaces. The absence of any record at the destination interface means the packets never arrived, so check Flow Logs on the transit gateway attachment or the source interface to see where they stop. Also check the source for a host firewall, and check for a DNS answer that points to a different address than the one you analyzed. A reject record at the destination would instead point to a security group or network ACL.
Exercise
A team has twelve VPCs on a transit gateway. One pair exchanges 40 TB a month and the other traffic is light. How can the team lower cost without losing the hub design?
Show answer
Add a VPC peering connection between the heavy pair and route their CIDRs to the peering connection. Peering has no hourly charge and no per-GB processing charge, so this removes that 40 TB from transit gateway data processing. The other ten VPCs keep using the hub. The team still pays standard data transfer rates for any traffic that crosses Availability Zones or Regions.