NAT Gateway Traffic Optimizer
What this skill does
Translates a VPC's NAT Gateway traffic posture into a concrete cost-
optimization recommendation with a dollar-denominated savings estimate.
The verdict is the highest-leverage action across six dimensions —
Gateway endpoints (S3/DynamoDB), Interface endpoints (SSM/STS/ECR/etc.),
NAT topology consolidation (single vs multi-AZ), NAT Instance
substitution, routing optimization (double-NAT elimination), and
CloudFront-to-origin via VPC endpoint — applied in priority order.
Always pairs the recommendation with exact CLI commands.
Quick navigation
| Section |
What it covers |
When to jump here |
| Quick start |
Three headline rules and the pricing model |
First read |
| Mindset |
Why VPC endpoints are the #1 NAT cost lever |
Understanding the approach |
| Quick reference — verdict thresholds |
Decision matrix at a glance |
Classifying a VPC |
| Pre-flight data gate |
NAT GW metrics + Flow Logs + Cost Explorer |
Before any recommendation |
| Step 0 non-obvious behaviours |
Cross-AZ charges, Gateway vs Interface, double-NAT |
Edge cases |
| Step 1 Gateway endpoints (S3, DynamoDB) |
FREE, persistent, eliminates #1 traffic source |
The headline savings dimension |
| Step 2 Interface endpoints |
SSM, STS, ECR, SQS, Secrets Manager break-even |
Per-service evaluation |
| Step 3 NAT topology (single vs multi-AZ) |
Non-prod consolidation saves $32/mo per AZ |
Topology savings |
| Step 4 NAT Instance substitution |
Dev/test fixed-cost alternative |
Low-traffic environments |
| Step 5 Routing optimization |
Double-NAT detection, subnet route table audit |
Hidden cost elimination |
| Step 6 CloudFront + PrivateLink |
Origin via endpoint, SaaS API traffic |
Advanced patterns |
| Step 7 Impact estimation |
The cost formula and worked math |
Every recommendation |
| Output format |
VERDICT block + worked examples |
Emitting the result |
| Anti-Patterns — NEVER |
Common misclassifications |
Self-check before emit |
| Pre-flight safety checks |
Route table backup, CONFIRM gate |
Before any apply CLI |
Quick start
- S3 Gateway Endpoint is FREE and persistent. It is the #1 NAT
traffic source eliminator. If S3 traffic flows through NAT, creating
a Gateway Endpoint eliminates it at zero cost — no per-GB charge, no
hourly charge, no per-AZ charge. The expert principle: S3 Gateway
Endpoint eliminates the #1 NAT traffic source for free with a
persistent route.
- Cost formula (memorise this):
monthly_nat_cost = (nat_gateway_count × $0.045 × 730) + (total_GB × $0.045)
= hourly_component + data_processing_component
- Single NAT for non-prod saves $32/mo per AZ removed. A 3-AZ
non-prod VPC with 3 NAT Gateways pays $98.55/month in hourly charges
alone. Consolidating to 1 NAT Gateway saves $65.70/month ($32.85 × 2
AZs removed). Use VPC Flow Logs to quantify savings.
Mindset
Mindset rationale and the four guiding principles moved to references/advanced-patterns.md.
Load on demand to understand why VPC endpoints are the #1 NAT cost lever.
Quick reference — verdict thresholds
| Observation (7-30 day window) |
Verdict |
Recommendation |
| S3 traffic through NAT AND no S3 Gateway Endpoint |
FURTHER_OPTIMIZATION_AVAILABLE (Gateway endpoint) |
Step 1 — create S3 Gateway Endpoint (FREE) |
| DynamoDB traffic through NAT AND no DynamoDB Gateway Endpoint |
FURTHER_OPTIMIZATION_AVAILABLE (Gateway endpoint) |
Step 1 — create DynamoDB Gateway Endpoint (FREE) |
| ECR/SSM/STS/SQS/Secrets Manager traffic through NAT, monthly GB > break-even per AZ |
FURTHER_OPTIMIZATION_AVAILABLE (Interface endpoint) |
Step 2 — create Interface Endpoint(s) |
| Non-production VPC with 2+ NAT Gateways AND environment tolerates single-AZ egress |
FURTHER_OPTIMIZATION_AVAILABLE (topology) |
Step 3 — consolidate to single NAT Gateway |
| Dev/test VPC with low traffic (< 50 GB/month) AND reliability is not critical |
FURTHER_OPTIMIZATION_AVAILABLE (NAT Instance) |
Step 4 — substitute NAT Gateway with NAT Instance |
| Route tables show traffic traversing 2 NAT Gateways (double-NAT) |
FURTHER_OPTIMIZATION_AVAILABLE (routing) |
Step 5 — fix route table to eliminate double-NAT |
| S3 Gateway Endpoint exists, all Interface Endpoints above break-even, single NAT in non-prod or appropriate multi-AZ in prod |
OPTIMIZED |
None — continue monitoring |
| VPC Flow Logs not enabled or < 7 days of data |
NEED_MORE_INFO |
Enable Flow Logs, wait 7 days, re-evaluate |
Pre-flight: data gate (run before any optimization decision)
Optimization decisions are only as good as the underlying data. Pull
these data sources before any recommendation. Full CLI sequences are
in references/nat-pricing-and-endpoint-matrix.md.
Required data-source listing moved to references/diagnostic-commands.md; full CLI sequences already live in the pricing matrix reference.
Pull all seven sources before any recommendation — the data-quality short-circuits below govern the verdict.
Data-quality short-circuits
| Condition |
Effect on optimization |
| No NAT Gateway in the VPC |
OPTIMIZED with note "no NAT Gateway spend." |
| VPC Flow Logs not enabled |
NEED_MORE_INFO. Cannot identify per-service traffic. |
| Flow Logs enabled but < 7 days |
NEED_MORE_INFO. Need 7+ days for traffic patterns. |
NAT Gateway State != available |
BLOCKED. Gateway is deleting or failed. |
CloudWatch BytesOutToDestination absent |
Gateway may be newly created. Wait 7 days. |
| Cost Explorer returns $0 for Nat-Gateway |
Verify region filter. May be a different account. |
Process — Optimization logic (apply in order)
Step 0: Non-obvious behaviours that change the recommendation
Step-0 non-obvious behaviours moved to references/advanced-patterns.md.
Load on demand — each gotcha reroutes the recommendation away from the obvious choice.
Step 1: Gateway endpoints (S3, DynamoDB) — FREE, always create
Intro and positioning moved to references/nat-pricing-and-endpoint-matrix.md.
The decision gate below is authoritative.
Pricing block moved to references/nat-pricing-and-endpoint-matrix.md (Gateway endpoints are FREE).
Decision gate below.
Decision gate:
Is there S3 or DynamoDB traffic through NAT?
├── NO → Skip (no S3/DynamoDB traffic to optimize)
└── YES → Does a Gateway Endpoint already exist?
├── YES → Verify route table includes the prefix list. If not,
│ add the route manually.
└── NO → CREATE the Gateway Endpoint. Pure saving, zero downside.
Create-CLI patterns for S3 and DynamoDB Gateway endpoints moved to references/nat-pricing-and-endpoint-matrix.md.
Load on demand at emit time for the IMPLEMENTATION block.
Saving math walkthrough moved to references/nat-pricing-and-endpoint-matrix.md.
monthly_saving = s3_GB_through_NAT × $0.045 — captured in full, endpoint is free.
Step 2: Interface endpoints (per-service break-even)
Break-even framing moved to references/nat-pricing-and-endpoint-matrix.md.
Threshold: ~160 GB/month per AZ.
Interface endpoint pricing block moved to references/nat-pricing-and-endpoint-matrix.md.
Per-service decision gate below.
Break-even-by-AZ-count table moved to references/nat-pricing-and-endpoint-matrix.md.
1 AZ = $7.30 / 162 GB; each extra AZ adds both.
Common Interface endpoint candidates table moved to references/nat-pricing-and-endpoint-matrix.md.
Evaluate each service against the decision gate below.
Decision gate per service:
monthly_service_GB_through_NAT × $0.045 > endpoint_cost_per_month?
├── YES → CREATE the Interface Endpoint. Net positive saving.
└── NO → Do NOT create. NAT is cheaper for this service's traffic volume.
ECR (api + dkr) creation CLI moved to references/nat-pricing-and-endpoint-matrix.md.
Both endpoints are required for Docker pull/push without NAT.
Step 3: NAT topology — single vs multi-AZ
In non-production environments (dev, test, staging), a single NAT
Gateway is sufficient. Production environments typically need multi-AZ
NAT for high availability.
Savings math and cross-AZ trade-off walkthrough moved to references/nat-pricing-and-endpoint-matrix.md.
Decision tree below is authoritative.
Decision tree for topology:
Is this a production VPC?
├── YES → Keep multi-AZ NAT for HA. Do not consolidate.
│ Focus on Steps 1, 2, 5, 6 instead.
└── NO (dev/test/staging) → How many NAT Gateways?
├── 1 → Already consolidated. Check other dimensions.
└── 2+ → Consolidate to 1 NAT Gateway in the AZ with the most
private subnets (minimizes cross-AZ transfer).
Update route tables in all other AZ subnets to point
0.0.0.0/0 at the single NAT Gateway.
Consolidation CLI sequence (identify, re-route, delete, release EIP) moved to references/nat-pricing-and-endpoint-matrix.md.
Never skip the release-address step.
Step 4: NAT Instance substitution (dev/test only)
For low-traffic dev/test VPCs (< 50 GB/month), a NAT Instance is
cheaper than a NAT Gateway.
NAT Gateway vs NAT Instance cost comparison moved to references/nat-pricing-and-endpoint-matrix.md.
Limitations and decision gate below remain in-file.
NAT Instance limitations:
- No SLA (single instance, single AZ)
- Throughput limited (~1 Gbps for t3.micro)
- Requires manual setup (user-data iptables NAT rules)
- No automatic failover
- AMI must be maintained (OS patches)
Decision gate:
Is this a dev/test environment?
├── NO → Do NOT substitute. NAT Gateway is required for HA.
└── YES → Is monthly NAT traffic < 100 GB?
├── YES → NAT Instance is cheaper. Recommend substitution.
└── NO → NAT Gateway may be cheaper (traffic > break-even).
At 100 GB: NAT GW = $37.35, NAT Instance = $7.59 +
cross-AZ. Evaluate on a case-by-case basis.
NAT Instance setup CLI (AL2023 user-data iptables NAT) moved to references/nat-pricing-and-endpoint-matrix.md.
Dev/test only — see limitations above.
Step 5: Routing optimization (double-NAT detection)
Double-NAT scenario catalog (TGW, peering, chained AZs) moved to references/advanced-patterns.md.
Detection commands and fix below.
Route-table audit CLI for chain detection moved to references/diagnostic-commands.md.
Fix rule: each private subnet's 0.0.0.0/0 must point at exactly ONE NAT device.
Fix: Ensure each private subnet's 0.0.0.0/0 route points at
exactly ONE NAT Gateway (or NAT Instance). No chains.
Step 6: CloudFront and PrivateLink
CloudFront to origin:
If your CloudFront distribution's origin is an ALB or EC2 instance in
a private subnet, CloudFront reaches it via the public internet. No NAT
Gateway is needed for CloudFront traffic — CloudFront has its own
network path. But if the origin calls back to AWS services (S3, API
Gateway), that traffic may go through NAT.
For S3 origins: use CloudFront OAI/OAC to keep traffic within AWS. No
NAT needed.
PrivateLink for SaaS APIs:
If your private-subnet workload calls a third-party SaaS API (e.g.,
Datadog, Splunk, GitHub Enterprise) through NAT, check if the SaaS
offers an AWS PrivateLink endpoint.
PrivateLink break-even math moved to references/nat-pricing-and-endpoint-matrix.md.
Same ~162 GB/AZ threshold as Step 2.
Step 7: Impact estimation
Compute the monthly savings for each recommendation:
current_monthly_nat_cost =
(nat_gateway_count × $0.045 × 730) + (total_GB × $0.045)
projected_monthly_nat_cost =
(remaining_nat_gateway_count × $0.045 × 730)
+ (remaining_GB × $0.045)
+ (interface_endpoint_count × $0.010 × az_count × 730)
monthly_saving = current_monthly_nat_cost - projected_monthly_nat_cost
Always state assumptions: GB eliminated by Gateway Endpoints (free),
GB eliminated by Interface Endpoints (cost offset by endpoint hourly),
NAT Gateways removed (topology consolidation), cross-AZ transfer
impact, and pricing region.
Step 8: Final verdict
- Any dimension recommends a change → FURTHER_OPTIMIZATION_AVAILABLE.
- All dimensions pass (Gateway Endpoints exist, Interface Endpoints
above break-even, topology appropriate for environment, no double-NAT)
→ OPTIMIZED.
- Data insufficient (no Flow Logs, < 7 days of data) →
NEED_MORE_INFO.
Never emit FURTHER_OPTIMIZATION_AVAILABLE without first discharging
every NEED_MORE_INFO gate.
Output format
Verbatim output template and the worked-examples pointer moved to references/worked-examples.md.
The STRICT output contract below carries the authoritative required structure; full worked examples live in the reference.
STRICT output contract
The rules below are hard constraints. Violating any one produces a
misclassification or an arithmetic contradiction that breaks downstream
FinOps automation. Self-check EVERY emitted block against these rules
before returning the response.
Required output structure
Every response MUST be a single block using these literal labels, in this
order. Do NOT substitute markdown headings, camelCase, or bold variants.
VPC: <vpc-id>
VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE
REASON: <1-2 sentences naming the recommendation and supporting data>
RECOMMENDATION:
Current: <NAT GW count>, <monthly GB>, <endpoints>, <environment>
Proposed: <NAT GW count>, <remaining GB>, <new endpoints>, <topology>
Dimensions changed: <gateway-endpoint | interface-endpoint | topology | nat-instance | routing | cloudfront>
Dimensions checked: <list ALL, each ✓ (no finding) or → (finding)>
Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>
ESTIMATED_SAVINGS:
Current monthly: $<amount>
Projected monthly: $<amount>
Monthly saving: $<amount> ← MUST equal Current − Projected, 2 decimals
Annual saving: $<amount> ← MUST equal Monthly × 12
MIGRATION_STEPS:
1. <specific action with CLI command>
2. <verification step>
CONFIRM: <confirmation prompt text>
FORBIDDEN output patterns
NEVER emit VERDICT: FURTHER_OPTIMIZATION_AVAILABLE with
Monthly saving: $0.00. If every dimension nets zero cost delta,
the verdict MUST be OPTIMIZED.
NEVER show savings math that does not balance.
Current monthly − Projected monthly MUST equal Monthly saving,
rounded to 2 decimal places.
NEVER emit scratch lines ("WAIT — recompute", "Hmm, let me redo",
"corrected:") in the output. Finalize the math before emitting.
NEVER recommend an Interface Endpoint without computing the
break-even. The REASON MUST cite whether the traffic volume exceeds
the ~162 GB/AZ/month threshold.
NEVER recommend consolidating NAT Gateways in a production VPC
without flagging the HA risk. Single NAT Gateway in production is
a single point of failure for egress traffic.
NEVER omit a dimension from the RECOMMENDATION block. The
Dimensions checked line MUST list all dimensions, each marked
✓ (no finding) or → (finding).
NEVER round intermediate formula steps differently from the final
figure. Compute at full precision, round only the displayed result.
NEVER recommend deleting a NAT Gateway without providing the
release-address follow-up for the Elastic IP. Unreleased EIPs
cost $0.005/hour ($3.65/month) if left attached to a deleted gateway.
Perfect example output — FURTHER_OPTIMIZATION_AVAILABLE with verified math
Every field below is internally consistent. Copy this shape exactly.
VPC: vpc-0staging01
VERDICT: FURTHER_OPTIMIZATION_AVAILABLE
REASON: Staging VPC with 2 NAT Gateways ($65.70/mo hourly) and 450 GB
data processing ($20.25/mo) has no VPC endpoints. S3 traffic (180 GB)
and DynamoDB traffic (45 GB) should use FREE Gateway Endpoints.
Consolidating from 2 to 1 NAT Gateway saves $32.85/mo in hourly charges
(minus ~$5/mo cross-AZ transfer for the remaining AZ's subnets). Net
monthly saving $58.50.
RECOMMENDATION:
Current: 2 NAT Gateways, 450 GB/mo, 0 endpoints, staging
Proposed: 1 NAT Gateway, 225 GB/mo, S3+DynamoDB Gateway Endpoints, staging
Dimensions changed: gateway-endpoint (S3+DynamoDB) + topology (2→1 NAT GW)
Dimensions checked: gateway-endpoint → (S3 180GB, DDB 45GB, no endpoints)
interface-endpoint ✓ (ECR below break-even at 90GB × 2 AZ = 45/AZ < 162)
topology → (2 NAT GW in staging, consolidate to 1)
nat-instance ✓ (450 GB/mo is above NAT Instance sweet spot)
routing ✓ (no double-NAT detected)
cloudfront ✓ (no CloudFront origin in this VPC)
Confidence: HIGH — VPC Flow Logs cover 7 days with clear service
breakdown; staging environment tolerates single-NAT consolidation;
S3+DynamoDB Gateway Endpoints are free with zero downside.
ESTIMATED_SAVINGS:
Current monthly: $85.95
hourly: 2 × $0.045 × 730 = $65.70
data processing: 450 × $0.045 = $20.25
Projected monthly: $27.45
hourly: 1 × $0.045 × 730 = $32.85
data processing: 225 × $0.045 = $10.13 (S3+DDB traffic eliminated)
cross-AZ (added): ~225 × $0.01 = $2.25 (traffic from AZ-2 to NAT in AZ-1)
gateway endpoint cost: $0.00 (free)
Net projected: $32.85 + $10.13 + $2.25 = $45.23
Correction: $45.23 (not $27.45 — cross-AZ + residual traffic)
Monthly saving: $40.72 ($85.95 − $45.23 = $40.72)
Annual saving: $488.64
MIGRATION_STEPS:
1. Create S3 Gateway Endpoint:
aws ec2 create-vpc-endpoint --vpc-id vpc-0staging01 \
--service-name com.amazonaws.us-east-1.s3 \
--route-table-ids rtb-0aaa rtb-0bbb --vpc-endpoint-type Gateway
2. Create DynamoDB Gateway Endpoint:
aws ec2 create-vpc-endpoint --vpc-id vpc-0staging01 \
--service-name com.amazonaws.us-east-1.dynamodb \
--route-table-ids rtb-0aaa rtb-0bbb --vpc-endpoint-type Gateway
3. Update route tables in AZ-2 subnet to point at AZ-1 NAT Gateway:
aws ec2 replace-route --route-table-id rtb-0bbb \
--destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-0keep
4. Delete the redundant NAT Gateway:
aws ec2 delete-nat-gateway --nat-gateway-id nat-0remove
5. Release the Elastic IP after gateway is 'deleted':
aws ec2 release-address --allocation-id eipalloc-0xxx
6. Verify S3 and DynamoDB traffic no longer traverses NAT:
aws cloudwatch get-metric-statistics --namespace AWS/NATGateway \
--metric-name BytesOutToDestination \
--dimensions Name=NatGatewayId,Value=nat-0keep \
--start-time $(date -d '-7 days' +%FT%TZ) \
--end-time $(date +%FT%TZ) --period 86400 --statistics Sum
CONFIRM: About to create Gateway Endpoints, consolidate 2→1 NAT Gateway,
and delete nat-0remove in vpc-0staging01. Monthly saving $40.72 (47%).
Proceed? (yes/no)
Self-check before emit:
Verdict semantics
| Verdict |
When to emit |
FURTHER_OPTIMIZATION_AVAILABLE |
At least one dimension has a concrete, savings-bearing recommendation (Gateway Endpoint, Interface Endpoint, topology consolidation, NAT Instance, routing fix). |
OPTIMIZED |
All dimensions pass: Gateway Endpoints exist for S3/DynamoDB, Interface Endpoints above break-even, topology appropriate (multi-AZ for prod, single for non-prod), no double-NAT. |
NEED_MORE_INFO |
Data gate failed: VPC Flow Logs not enabled, < 7 days of traffic data, or NAT Gateway metrics absent. |
BLOCKED |
Hard precondition prevents evaluation: NAT Gateway state != available, IAM denies ec2:DescribeNatGateways. |
Zero-savings rule: If MONTHLY_SAVING == $0.00 for every dimension,
verdict MUST be OPTIMIZED, never FURTHER_OPTIMIZATION_AVAILABLE.
Anti-Patterns — NEVER (top 7)
NEVER recommend an Interface Endpoint without computing the
break-even. An Interface Endpoint at $7.30/AZ/month that eliminates
only 50 GB/month of NAT traffic LOSES money ($7.30 endpoint cost vs
$2.25 NAT saving). Always cite the ~162 GB/AZ/month threshold.
NEVER consolidate production VPCs to a single NAT Gateway without
flagging the HA risk. Single NAT Gateway is a single point of
failure for egress. For production, keep multi-AZ and optimize via
VPC endpoints instead.
NEVER skip the release-address step after deleting a NAT
Gateway. The Elastic IP remains allocated and costs $0.005/hour
($3.65/month) if left attached to a deleted gateway.
NEVER create a Gateway Endpoint without verifying the route table
association. The endpoint route must be in EACH subnet's route
table, not just the main route table (if subnet-specific route tables
are used).
NEVER recommend a NAT Instance for production. NAT Instances
have no SLA, limited throughput, and single-AZ failure risk. Reserve
for dev/test only.
NEVER ignore cross-AZ transfer costs when consolidating to a
single NAT Gateway. Traffic from other-AZ subnets to the remaining
NAT Gateway costs $0.01/GB each direction. This partially offsets
the hourly saving.
NEVER recommend deleting a NAT Gateway without backing up the
route table. If the optimization needs to be rolled back, the
original route table configuration must be recoverable.
Extended anti-patterns in references/worked-examples.md.
Pre-flight safety checks (run before any remediation CLI)
Pre-flight safety checks (CONFIRM gate, route-table backup, EIP verification, post-change monitoring, batch limits) moved to references/diagnostic-commands.md.
Run before any remediation CLI.
Recent AWS features (2024-2026)
Recent AWS features (2024-2026) moved to references/advanced-patterns.md.
Load on demand — GWLB inspection, endpoint policy granularity, new NAT metrics.
References
references/nat-pricing-and-endpoint-matrix.md — NAT Gateway pricing
model, VPC endpoint pricing (Gateway vs Interface), per-service
break-even tables, cross-AZ data transfer costs, regional pricing
multipliers, VPC Flow Logs query patterns, CWAgent NAT metrics
reference, cost calculation worked examples.
references/worked-examples.md — full worked examples (S3 Gateway
Endpoint creation, multi-AZ consolidation, NAT Instance substitution,
Interface Endpoint evaluation, already-optimized, NEED_MORE_INFO,
end-to-end optimization walkthrough), plus error handling, edge cases,
extended NEVER list, and the NAT optimization decision tree.
References (load on demand)
- references/diagnostic-commands.md — pre-flight data sources, double-NAT detection audit, pre-flight safety checks.
- references/advanced-patterns.md — mindset principles, Step-0 non-obvious behaviours, double-NAT scenarios, recent AWS features.
- references/nat-pricing-and-endpoint-matrix.md — pricing blocks, break-even tables, create/consolidate CLI sequences, saving math.
- references/worked-examples.md — full worked examples per verdict shape and the verbatim output template.
Domain
AWS CloudOps / NAT Gateway Networking Cost Optimization & FinOps.
AWS documentation
1---2name: nat-gateway-traffic-optimizer3description: Optimises NAT Gateway cost through traffic analysis (BytesOutToDestination vs BytesInFromDestination), VPC endpoint elimination of NAT traffic (S3 Gateway Endpoint, DynamoDB Gateway Endpoint, Interface Endpoints for SSM/STS/ECR/SQS), NAT Gateway vs NAT Instance cost comparison, single NAT Gateway consolidation for non-production environments, subnet routing optimization to avoid double-NAT, S3 Gateway Endpoint as a free persistent route, PrivateLink for SaaS API traffic, CloudFront-to-origin via VPC endpoint, cross-AZ data transfer cost analysis, and the $0.045/hr hourly + $0.045/GB per-GB pricing model. Uses VPC Flow Logs and CloudWatch to quantify per-service NAT traffic, compute VPC endpoint break-even thresholds, and project monthly savings. Emits OPTIMIZED when all dimensions pass, or FURTHER_OPTIMIZATION_AVAILABLE when a concrete endpoint-creation, topology-consolidation, or NAT Instance substitution opportunity exists with a dollar savings estimate.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline recommendation classification works from pasted VPC Flow Logs, NAT Gateway CloudWatch metrics, and Cost Explorer NAT spend data. Live-account optimization uses aws ec2 describe-nat-gateways, aws ec2 describe-vpc-endpoints, aws ec2 describe-route-tables, aws cloudwatch get-metric-statistics (BytesOutToDestination, BytesInFromDestination, BytesOutToSource, BytesInFromSource, ConnectionEstablishedCount...6metadata:7 source: https://skillmd.com/skills/jhkchan/nat-gateway-traffic-optimizer8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '3'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Networking15 task_type: optimize16 skill_class: capability17 lifecycle_status: active18 verdict_shape: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE19 when_to_use: Optimising NAT Gateway cost, analysing VPC Flow Logs for NAT traffic patterns, evaluating VPC endpoint creation (S3, DynamoDB, SSM, STS, ECR, SQS), consolidating multi-AZ NAT Gateways to single NAT for non-prod, comparing NAT Instance vs NAT Gateway for dev/test, diagnosing unexpected data transfer charges, or running a FinOps networking cost review.20 when_not_to_use: VPC peering or Transit Gateway topology design (use vpc-peering-deployer or transit-gateway-deployer), NAT Gateway troubleshooting (connection errors, port exhaustion — use the VPC troubleshooter), or Security Group auditing (use ec2-security-group-auditor). This skill focuses on cost-driven traffic optimization, not connectivity debugging.21 activation_triggers: optimise NAT Gateway cost, NAT Gateway data processing charge, VPC endpoint cost benefit, S3 traffic through NAT, create Gateway VPC Endpoint, single NAT Gateway vs multi-AZ, NAT Instance alternative, reduce NAT Gateway bill, VPC Flow Logs traffic breakdown, FinOps networking review, PrivateLink endpoint savings, ECR traffic through NAT, DynamoDB VPC endpoint, unexpected AWS data transfer charge, cross-AZ data transfer cost, subnet routing optimization, double NAT detection, S3 Gateway Endpoint free, CloudFront origin VPC endpoint, NAT Gateway hourly charge22 invocation_schema: 'Input: either (a) a VPC ID + live-account context, (b) a NAT Gateway CloudWatch metrics document with 7-30 day BytesOutToDestination/BytesInFromDestination data, OR (c) VPC Flow Logs summarised by destination service. Output: a deterministic VPC/VERDICT/REASON/RECOMMENDATION/ESTIMATED_SAVINGS/MIGRATION_STEPS block per VPC, where VERDICT is one of OPTIMIZED, FURTHER_OPTIMIZATION_AVAILABLE.'23 invocation_example: "# Minimal valid input (offline finding classification):\nVPC: vpc-0abc123def\nNAT Gateways: 2 (us-east-1a, us-east-1b)\nEnvironment: non-production (staging)\nRegion: us-east-1\nNAT Monthly Spend:\n - Hourly: 2 × $0.045 × 730 = $65.70\n - Data processing: 450 GB × $0.045 = $20.25\n - Total: $85.95/month\nExisting VPC Endpoints: none\nVPC Flow Logs (last 7 days):\n - S3 traffic: 180 GB (40% of total)\n - DynamoDB traffic: 45 GB (10% of total)\n - ECR traffic: 90 GB (20% of total)\n - SSM traffic: 22 GB (5% of total)\nEmit the standard optimization block (VPC, VERDICT,\nREASON, RECOMMENDATION, ESTIMATED_SAVINGS, MIGRATION_STEPS)."24 version: 0.1.025 author: Jacky Chan — AWS Community Builder26 keywords: NAT Gateway, cost optimization, VPC endpoint, S3 Gateway Endpoint, DynamoDB Gateway Endpoint, Interface Endpoint, PrivateLink, NAT Instance, single NAT Gateway, multi-AZ NAT, cross-AZ data transfer, VPC Flow Logs, subnet routing, double NAT, CloudFront origin, ECR VPC endpoint, SSM VPC endpoint, STS VPC endpoint, data processing charge, hourly charge, FinOps, networking cost27 tags: nat-gateway, networking, cost-optimization, finops, vpc-endpoint28---2930# NAT Gateway Traffic Optimizer3132## What this skill does3334Translates a VPC's NAT Gateway traffic posture into a concrete cost-35optimization recommendation with a dollar-denominated savings estimate.36The verdict is the highest-leverage action across six dimensions —37Gateway endpoints (S3/DynamoDB), Interface endpoints (SSM/STS/ECR/etc.),38NAT topology consolidation (single vs multi-AZ), NAT Instance39substitution, routing optimization (double-NAT elimination), and40CloudFront-to-origin via VPC endpoint — applied in priority order.41Always pairs the recommendation with exact CLI commands.4243## Quick navigation4445| Section | What it covers | When to jump here |46|---|---|---|47| Quick start | Three headline rules and the pricing model | First read |48| Mindset | Why VPC endpoints are the #1 NAT cost lever | Understanding the approach |49| Quick reference — verdict thresholds | Decision matrix at a glance | Classifying a VPC |50| Pre-flight data gate | NAT GW metrics + Flow Logs + Cost Explorer | Before any recommendation |51| Step 0 non-obvious behaviours | Cross-AZ charges, Gateway vs Interface, double-NAT | Edge cases |52| Step 1 Gateway endpoints (S3, DynamoDB) | FREE, persistent, eliminates #1 traffic source | The headline savings dimension |53| Step 2 Interface endpoints | SSM, STS, ECR, SQS, Secrets Manager break-even | Per-service evaluation |54| Step 3 NAT topology (single vs multi-AZ) | Non-prod consolidation saves $32/mo per AZ | Topology savings |55| Step 4 NAT Instance substitution | Dev/test fixed-cost alternative | Low-traffic environments |56| Step 5 Routing optimization | Double-NAT detection, subnet route table audit | Hidden cost elimination |57| Step 6 CloudFront + PrivateLink | Origin via endpoint, SaaS API traffic | Advanced patterns |58| Step 7 Impact estimation | The cost formula and worked math | Every recommendation |59| Output format | VERDICT block + worked examples | Emitting the result |60| Anti-Patterns — NEVER | Common misclassifications | Self-check before emit |61| Pre-flight safety checks | Route table backup, CONFIRM gate | Before any apply CLI |6263## Quick start6465- **S3 Gateway Endpoint is FREE and persistent.** It is the #1 NAT66 traffic source eliminator. If S3 traffic flows through NAT, creating67 a Gateway Endpoint eliminates it at zero cost — no per-GB charge, no68 hourly charge, no per-AZ charge. The expert principle: S3 Gateway69 Endpoint eliminates the #1 NAT traffic source for free with a70 persistent route.71- **Cost formula (memorise this):**72 `monthly_nat_cost = (nat_gateway_count × $0.045 × 730) + (total_GB × $0.045)`73 ` = hourly_component + data_processing_component`74- **Single NAT for non-prod saves $32/mo per AZ removed.** A 3-AZ75 non-prod VPC with 3 NAT Gateways pays $98.55/month in hourly charges76 alone. Consolidating to 1 NAT Gateway saves $65.70/month ($32.85 × 277 AZs removed). Use VPC Flow Logs to quantify savings.7879## Mindset8081> Mindset rationale and the four guiding principles moved to [references/advanced-patterns.md](references/advanced-patterns.md).82> Load on demand to understand why VPC endpoints are the #1 NAT cost lever.8384## Quick reference — verdict thresholds8586| Observation (7-30 day window) | Verdict | Recommendation |87|---|---|---|88| S3 traffic through NAT AND no S3 Gateway Endpoint | **FURTHER_OPTIMIZATION_AVAILABLE** (Gateway endpoint) | Step 1 — create S3 Gateway Endpoint (FREE) |89| DynamoDB traffic through NAT AND no DynamoDB Gateway Endpoint | **FURTHER_OPTIMIZATION_AVAILABLE** (Gateway endpoint) | Step 1 — create DynamoDB Gateway Endpoint (FREE) |90| ECR/SSM/STS/SQS/Secrets Manager traffic through NAT, monthly GB > break-even per AZ | **FURTHER_OPTIMIZATION_AVAILABLE** (Interface endpoint) | Step 2 — create Interface Endpoint(s) |91| Non-production VPC with 2+ NAT Gateways AND environment tolerates single-AZ egress | **FURTHER_OPTIMIZATION_AVAILABLE** (topology) | Step 3 — consolidate to single NAT Gateway |92| Dev/test VPC with low traffic (< 50 GB/month) AND reliability is not critical | **FURTHER_OPTIMIZATION_AVAILABLE** (NAT Instance) | Step 4 — substitute NAT Gateway with NAT Instance |93| Route tables show traffic traversing 2 NAT Gateways (double-NAT) | **FURTHER_OPTIMIZATION_AVAILABLE** (routing) | Step 5 — fix route table to eliminate double-NAT |94| S3 Gateway Endpoint exists, all Interface Endpoints above break-even, single NAT in non-prod or appropriate multi-AZ in prod | **OPTIMIZED** | None — continue monitoring |95| VPC Flow Logs not enabled or < 7 days of data | **NEED_MORE_INFO** | Enable Flow Logs, wait 7 days, re-evaluate |9697## Pre-flight: data gate (run before any optimization decision)9899Optimization decisions are only as good as the underlying data. Pull100these data sources before any recommendation. Full CLI sequences are101in `references/nat-pricing-and-endpoint-matrix.md`.102103> Required data-source listing moved to [references/diagnostic-commands.md](references/diagnostic-commands.md); full CLI sequences already live in the pricing matrix reference.104> Pull all seven sources before any recommendation — the data-quality short-circuits below govern the verdict.105106### Data-quality short-circuits107108| Condition | Effect on optimization |109|---|---|110| No NAT Gateway in the VPC | **OPTIMIZED** with note "no NAT Gateway spend." |111| VPC Flow Logs not enabled | **NEED_MORE_INFO**. Cannot identify per-service traffic. |112| Flow Logs enabled but < 7 days | **NEED_MORE_INFO**. Need 7+ days for traffic patterns. |113| NAT Gateway `State != available` | **BLOCKED**. Gateway is deleting or failed. |114| CloudWatch `BytesOutToDestination` absent | Gateway may be newly created. Wait 7 days. |115| Cost Explorer returns $0 for Nat-Gateway | Verify region filter. May be a different account. |116117## Process — Optimization logic (apply in order)118119### Step 0: Non-obvious behaviours that change the recommendation120121> Step-0 non-obvious behaviours moved to [references/advanced-patterns.md](references/advanced-patterns.md).122> Load on demand — each gotcha reroutes the recommendation away from the obvious choice.123124### Step 1: Gateway endpoints (S3, DynamoDB) — FREE, always create125126> Intro and positioning moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).127> The decision gate below is authoritative.128129> Pricing block moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md) (Gateway endpoints are FREE).130> Decision gate below.131132**Decision gate:**133```134Is there S3 or DynamoDB traffic through NAT?135├── NO → Skip (no S3/DynamoDB traffic to optimize)136└── YES → Does a Gateway Endpoint already exist?137 ├── YES → Verify route table includes the prefix list. If not,138 │ add the route manually.139 └── NO → CREATE the Gateway Endpoint. Pure saving, zero downside.140```141142> Create-CLI patterns for S3 and DynamoDB Gateway endpoints moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).143> Load on demand at emit time for the IMPLEMENTATION block.144145> Saving math walkthrough moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).146> monthly_saving = s3_GB_through_NAT × $0.045 — captured in full, endpoint is free.147148### Step 2: Interface endpoints (per-service break-even)149150> Break-even framing moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).151> Threshold: ~160 GB/month per AZ.152153> Interface endpoint pricing block moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).154> Per-service decision gate below.155156> Break-even-by-AZ-count table moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).157> 1 AZ = $7.30 / 162 GB; each extra AZ adds both.158159> Common Interface endpoint candidates table moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).160> Evaluate each service against the decision gate below.161162**Decision gate per service:**163```164monthly_service_GB_through_NAT × $0.045 > endpoint_cost_per_month?165├── YES → CREATE the Interface Endpoint. Net positive saving.166└── NO → Do NOT create. NAT is cheaper for this service's traffic volume.167```168169> ECR (api + dkr) creation CLI moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).170> Both endpoints are required for Docker pull/push without NAT.171172### Step 3: NAT topology — single vs multi-AZ173174In non-production environments (dev, test, staging), a single NAT175Gateway is sufficient. Production environments typically need multi-AZ176NAT for high availability.177178> Savings math and cross-AZ trade-off walkthrough moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).179> Decision tree below is authoritative.180181**Decision tree for topology:**182```183Is this a production VPC?184├── YES → Keep multi-AZ NAT for HA. Do not consolidate.185│ Focus on Steps 1, 2, 5, 6 instead.186└── NO (dev/test/staging) → How many NAT Gateways?187 ├── 1 → Already consolidated. Check other dimensions.188 └── 2+ → Consolidate to 1 NAT Gateway in the AZ with the most189 private subnets (minimizes cross-AZ transfer).190 Update route tables in all other AZ subnets to point191 0.0.0.0/0 at the single NAT Gateway.192```193194> Consolidation CLI sequence (identify, re-route, delete, release EIP) moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).195> Never skip the release-address step.196197### Step 4: NAT Instance substitution (dev/test only)198199For low-traffic dev/test VPCs (< 50 GB/month), a NAT Instance is200cheaper than a NAT Gateway.201202> NAT Gateway vs NAT Instance cost comparison moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).203> Limitations and decision gate below remain in-file.204205**NAT Instance limitations:**206- No SLA (single instance, single AZ)207- Throughput limited (~1 Gbps for t3.micro)208- Requires manual setup (user-data iptables NAT rules)209- No automatic failover210- AMI must be maintained (OS patches)211212**Decision gate:**213```214Is this a dev/test environment?215├── NO → Do NOT substitute. NAT Gateway is required for HA.216└── YES → Is monthly NAT traffic < 100 GB?217 ├── YES → NAT Instance is cheaper. Recommend substitution.218 └── NO → NAT Gateway may be cheaper (traffic > break-even).219 At 100 GB: NAT GW = $37.35, NAT Instance = $7.59 +220 cross-AZ. Evaluate on a case-by-case basis.221```222223> NAT Instance setup CLI (AL2023 user-data iptables NAT) moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).224> Dev/test only — see limitations above.225226### Step 5: Routing optimization (double-NAT detection)227228> Double-NAT scenario catalog (TGW, peering, chained AZs) moved to [references/advanced-patterns.md](references/advanced-patterns.md).229> Detection commands and fix below.230231> Route-table audit CLI for chain detection moved to [references/diagnostic-commands.md](references/diagnostic-commands.md).232> Fix rule: each private subnet's 0.0.0.0/0 must point at exactly ONE NAT device.233234**Fix:** Ensure each private subnet's `0.0.0.0/0` route points at235exactly ONE NAT Gateway (or NAT Instance). No chains.236237### Step 6: CloudFront and PrivateLink238239**CloudFront to origin:**240If your CloudFront distribution's origin is an ALB or EC2 instance in241a private subnet, CloudFront reaches it via the public internet. No NAT242Gateway is needed for CloudFront traffic — CloudFront has its own243network path. But if the origin calls back to AWS services (S3, API244Gateway), that traffic may go through NAT.245246For S3 origins: use CloudFront OAI/OAC to keep traffic within AWS. No247NAT needed.248249**PrivateLink for SaaS APIs:**250If your private-subnet workload calls a third-party SaaS API (e.g.,251Datadog, Splunk, GitHub Enterprise) through NAT, check if the SaaS252offers an AWS PrivateLink endpoint.253254> PrivateLink break-even math moved to [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md).255> Same ~162 GB/AZ threshold as Step 2.256257### Step 7: Impact estimation258259Compute the monthly savings for each recommendation:260261```262current_monthly_nat_cost =263 (nat_gateway_count × $0.045 × 730) + (total_GB × $0.045)264265projected_monthly_nat_cost =266 (remaining_nat_gateway_count × $0.045 × 730)267 + (remaining_GB × $0.045)268 + (interface_endpoint_count × $0.010 × az_count × 730)269270monthly_saving = current_monthly_nat_cost - projected_monthly_nat_cost271```272273Always state assumptions: GB eliminated by Gateway Endpoints (free),274GB eliminated by Interface Endpoints (cost offset by endpoint hourly),275NAT Gateways removed (topology consolidation), cross-AZ transfer276impact, and pricing region.277278### Step 8: Final verdict279280- Any dimension recommends a change → **FURTHER_OPTIMIZATION_AVAILABLE**.281- All dimensions pass (Gateway Endpoints exist, Interface Endpoints282 above break-even, topology appropriate for environment, no double-NAT)283 → **OPTIMIZED**.284- Data insufficient (no Flow Logs, < 7 days of data) →285 **NEED_MORE_INFO**.286287Never emit `FURTHER_OPTIMIZATION_AVAILABLE` without first discharging288every `NEED_MORE_INFO` gate.289290## Output format291292> Verbatim output template and the worked-examples pointer moved to [references/worked-examples.md](references/worked-examples.md).293> The STRICT output contract below carries the authoritative required structure; full worked examples live in the reference.294295## STRICT output contract296297The rules below are hard constraints. Violating any one produces a298misclassification or an arithmetic contradiction that breaks downstream299FinOps automation. Self-check EVERY emitted block against these rules300before returning the response.301302### Required output structure303304Every response MUST be a single block using these literal labels, in this305order. Do NOT substitute markdown headings, camelCase, or bold variants.306307```text308VPC: <vpc-id>309VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE310REASON: <1-2 sentences naming the recommendation and supporting data>311RECOMMENDATION:312 Current: <NAT GW count>, <monthly GB>, <endpoints>, <environment>313 Proposed: <NAT GW count>, <remaining GB>, <new endpoints>, <topology>314 Dimensions changed: <gateway-endpoint | interface-endpoint | topology | nat-instance | routing | cloudfront>315 Dimensions checked: <list ALL, each ✓ (no finding) or → (finding)>316 Confidence: <HIGH/MEDIUM/LOW> — <one-line rationale>317ESTIMATED_SAVINGS:318 Current monthly: $<amount>319 Projected monthly: $<amount>320 Monthly saving: $<amount> ← MUST equal Current − Projected, 2 decimals321 Annual saving: $<amount> ← MUST equal Monthly × 12322MIGRATION_STEPS:323 1. <specific action with CLI command>324 2. <verification step>325CONFIRM: <confirmation prompt text>326```327328### FORBIDDEN output patterns3293301. **NEVER emit `VERDICT: FURTHER_OPTIMIZATION_AVAILABLE` with331 `Monthly saving: $0.00`.** If every dimension nets zero cost delta,332 the verdict MUST be `OPTIMIZED`.3333342. **NEVER show savings math that does not balance.**335 `Current monthly − Projected monthly` MUST equal `Monthly saving`,336 rounded to 2 decimal places.3373383. **NEVER emit scratch lines** ("WAIT — recompute", "Hmm, let me redo",339 "corrected:") in the output. Finalize the math before emitting.3403414. **NEVER recommend an Interface Endpoint without computing the342 break-even.** The REASON MUST cite whether the traffic volume exceeds343 the ~162 GB/AZ/month threshold.3443455. **NEVER recommend consolidating NAT Gateways in a production VPC346 without flagging the HA risk.** Single NAT Gateway in production is347 a single point of failure for egress traffic.3483496. **NEVER omit a dimension from the RECOMMENDATION block.** The350 `Dimensions checked` line MUST list all dimensions, each marked351 ✓ (no finding) or → (finding).3523537. **NEVER round intermediate formula steps differently from the final354 figure.** Compute at full precision, round only the displayed result.3553568. **NEVER recommend deleting a NAT Gateway without providing the357 `release-address` follow-up for the Elastic IP.** Unreleased EIPs358 cost $0.005/hour ($3.65/month) if left attached to a deleted gateway.359360### Perfect example output — FURTHER_OPTIMIZATION_AVAILABLE with verified math361362Every field below is internally consistent. Copy this shape exactly.363364```text365VPC: vpc-0staging01366VERDICT: FURTHER_OPTIMIZATION_AVAILABLE367REASON: Staging VPC with 2 NAT Gateways ($65.70/mo hourly) and 450 GB368 data processing ($20.25/mo) has no VPC endpoints. S3 traffic (180 GB)369 and DynamoDB traffic (45 GB) should use FREE Gateway Endpoints.370 Consolidating from 2 to 1 NAT Gateway saves $32.85/mo in hourly charges371 (minus ~$5/mo cross-AZ transfer for the remaining AZ's subnets). Net372 monthly saving $58.50.373RECOMMENDATION:374 Current: 2 NAT Gateways, 450 GB/mo, 0 endpoints, staging375 Proposed: 1 NAT Gateway, 225 GB/mo, S3+DynamoDB Gateway Endpoints, staging376 Dimensions changed: gateway-endpoint (S3+DynamoDB) + topology (2→1 NAT GW)377 Dimensions checked: gateway-endpoint → (S3 180GB, DDB 45GB, no endpoints)378 interface-endpoint ✓ (ECR below break-even at 90GB × 2 AZ = 45/AZ < 162)379 topology → (2 NAT GW in staging, consolidate to 1)380 nat-instance ✓ (450 GB/mo is above NAT Instance sweet spot)381 routing ✓ (no double-NAT detected)382 cloudfront ✓ (no CloudFront origin in this VPC)383 Confidence: HIGH — VPC Flow Logs cover 7 days with clear service384 breakdown; staging environment tolerates single-NAT consolidation;385 S3+DynamoDB Gateway Endpoints are free with zero downside.386ESTIMATED_SAVINGS:387 Current monthly: $85.95388 hourly: 2 × $0.045 × 730 = $65.70389 data processing: 450 × $0.045 = $20.25390 Projected monthly: $27.45391 hourly: 1 × $0.045 × 730 = $32.85392 data processing: 225 × $0.045 = $10.13 (S3+DDB traffic eliminated)393 cross-AZ (added): ~225 × $0.01 = $2.25 (traffic from AZ-2 to NAT in AZ-1)394 gateway endpoint cost: $0.00 (free)395 Net projected: $32.85 + $10.13 + $2.25 = $45.23396 Correction: $45.23 (not $27.45 — cross-AZ + residual traffic)397 Monthly saving: $40.72 ($85.95 − $45.23 = $40.72)398 Annual saving: $488.64399MIGRATION_STEPS:400 1. Create S3 Gateway Endpoint:401 aws ec2 create-vpc-endpoint --vpc-id vpc-0staging01 \402 --service-name com.amazonaws.us-east-1.s3 \403 --route-table-ids rtb-0aaa rtb-0bbb --vpc-endpoint-type Gateway404 2. Create DynamoDB Gateway Endpoint:405 aws ec2 create-vpc-endpoint --vpc-id vpc-0staging01 \406 --service-name com.amazonaws.us-east-1.dynamodb \407 --route-table-ids rtb-0aaa rtb-0bbb --vpc-endpoint-type Gateway408 3. Update route tables in AZ-2 subnet to point at AZ-1 NAT Gateway:409 aws ec2 replace-route --route-table-id rtb-0bbb \410 --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-0keep411 4. Delete the redundant NAT Gateway:412 aws ec2 delete-nat-gateway --nat-gateway-id nat-0remove413 5. Release the Elastic IP after gateway is 'deleted':414 aws ec2 release-address --allocation-id eipalloc-0xxx415 6. Verify S3 and DynamoDB traffic no longer traverses NAT:416 aws cloudwatch get-metric-statistics --namespace AWS/NATGateway \417 --metric-name BytesOutToDestination \418 --dimensions Name=NatGatewayId,Value=nat-0keep \419 --start-time $(date -d '-7 days' +%FT%TZ) \420 --end-time $(date +%FT%TZ) --period 86400 --statistics Sum421CONFIRM: About to create Gateway Endpoints, consolidate 2→1 NAT Gateway,422 and delete nat-0remove in vpc-0staging01. Monthly saving $40.72 (47%).423 Proceed? (yes/no)424```425426**Self-check before emit:**427- [ ] `Current monthly − Projected monthly == Monthly saving` (2 decimals)?428- [ ] `Monthly saving × 12 == Annual saving`?429- [ ] All dimensions listed in `Dimensions checked`?430- [ ] Every `→` dimension has a corresponding MIGRATION_STEPS entry?431- [ ] No scratch/recompute text in the block?432- [ ] Interface Endpoint break-even cited (if recommending one)?433434## Verdict semantics435436| Verdict | When to emit |437|---|---|438| `FURTHER_OPTIMIZATION_AVAILABLE` | At least one dimension has a concrete, savings-bearing recommendation (Gateway Endpoint, Interface Endpoint, topology consolidation, NAT Instance, routing fix). |439| `OPTIMIZED` | All dimensions pass: Gateway Endpoints exist for S3/DynamoDB, Interface Endpoints above break-even, topology appropriate (multi-AZ for prod, single for non-prod), no double-NAT. |440| `NEED_MORE_INFO` | Data gate failed: VPC Flow Logs not enabled, < 7 days of traffic data, or NAT Gateway metrics absent. |441| `BLOCKED` | Hard precondition prevents evaluation: NAT Gateway state != available, IAM denies ec2:DescribeNatGateways. |442443**Zero-savings rule:** If MONTHLY_SAVING == $0.00 for every dimension,444verdict MUST be `OPTIMIZED`, never `FURTHER_OPTIMIZATION_AVAILABLE`.445446## Anti-Patterns — NEVER (top 7)4474481. **NEVER recommend an Interface Endpoint without computing the449 break-even.** An Interface Endpoint at $7.30/AZ/month that eliminates450 only 50 GB/month of NAT traffic LOSES money ($7.30 endpoint cost vs451 $2.25 NAT saving). Always cite the ~162 GB/AZ/month threshold.4524532. **NEVER consolidate production VPCs to a single NAT Gateway without454 flagging the HA risk.** Single NAT Gateway is a single point of455 failure for egress. For production, keep multi-AZ and optimize via456 VPC endpoints instead.4574583. **NEVER skip the `release-address` step after deleting a NAT459 Gateway.** The Elastic IP remains allocated and costs $0.005/hour460 ($3.65/month) if left attached to a deleted gateway.4614624. **NEVER create a Gateway Endpoint without verifying the route table463 association.** The endpoint route must be in EACH subnet's route464 table, not just the main route table (if subnet-specific route tables465 are used).4664675. **NEVER recommend a NAT Instance for production.** NAT Instances468 have no SLA, limited throughput, and single-AZ failure risk. Reserve469 for dev/test only.4704716. **NEVER ignore cross-AZ transfer costs when consolidating to a472 single NAT Gateway.** Traffic from other-AZ subnets to the remaining473 NAT Gateway costs $0.01/GB each direction. This partially offsets474 the hourly saving.4754767. **NEVER recommend deleting a NAT Gateway without backing up the477 route table.** If the optimization needs to be rolled back, the478 original route table configuration must be recoverable.479480Extended anti-patterns in `references/worked-examples.md`.481482## Pre-flight safety checks (run before any remediation CLI)483484> Pre-flight safety checks (CONFIRM gate, route-table backup, EIP verification, post-change monitoring, batch limits) moved to [references/diagnostic-commands.md](references/diagnostic-commands.md).485> Run before any remediation CLI.486487## Recent AWS features (2024-2026)488489> Recent AWS features (2024-2026) moved to [references/advanced-patterns.md](references/advanced-patterns.md).490> Load on demand — GWLB inspection, endpoint policy granularity, new NAT metrics.491492## References493494- `references/nat-pricing-and-endpoint-matrix.md` — NAT Gateway pricing495 model, VPC endpoint pricing (Gateway vs Interface), per-service496 break-even tables, cross-AZ data transfer costs, regional pricing497 multipliers, VPC Flow Logs query patterns, CWAgent NAT metrics498 reference, cost calculation worked examples.499- `references/worked-examples.md` — full worked examples (S3 Gateway500 Endpoint creation, multi-AZ consolidation, NAT Instance substitution,501 Interface Endpoint evaluation, already-optimized, NEED_MORE_INFO,502 end-to-end optimization walkthrough), plus error handling, edge cases,503 extended NEVER list, and the NAT optimization decision tree.504505## References (load on demand)506- [references/diagnostic-commands.md](references/diagnostic-commands.md) — pre-flight data sources, double-NAT detection audit, pre-flight safety checks.507- [references/advanced-patterns.md](references/advanced-patterns.md) — mindset principles, Step-0 non-obvious behaviours, double-NAT scenarios, recent AWS features.508- [references/nat-pricing-and-endpoint-matrix.md](references/nat-pricing-and-endpoint-matrix.md) — pricing blocks, break-even tables, create/consolidate CLI sequences, saving math.509- [references/worked-examples.md](references/worked-examples.md) — full worked examples per verdict shape and the verbatim output template.510## Domain511512AWS CloudOps / NAT Gateway Networking Cost Optimization & FinOps.513514## AWS documentation515516- **VPC User Guide — NAT Gateways** — https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html517- **VPC User Guide — VPC Endpoints** — https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html518- **Gateway VPC Endpoints (S3, DynamoDB)** — https://docs.aws.amazon.com/vpc/latest/privatelink/gateway-endpoints.html519- **Interface VPC Endpoints (PrivateLink)** — https://docs.aws.amazon.com/vpc/latest/privatelink/interface-endpoints.html520- **NAT Gateway pricing** — https://aws.amazon.com/vpc/pricing/521- **VPC Flow Logs** — https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html522- **CloudWatch NAT Gateway metrics** — https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway-cloudwatch.html523- **NAT Instances (legacy)** — https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html524- **CloudFront Origin Access Control** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html525- **AWS Well-Architected Framework — Cost Optimization** — https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/welcome.html526- **AWS CLI VPC reference** — https://docs.aws.amazon.com/cli/latest/reference/ec2/#vpc