ရိုးရိုးလေး ရှင်းပြမယ်
ရိုးရိုးလေး ရှင်းပြရရင်
VPC peering ဆိုတာ မြို့တစ်စုံချင်းစီကြားမှာ private တံတားတစ်စင်းစီ ဆောက်တာနဲ့ တူပါတယ်။ မြို့သုံးမြို့ဆိုရင် တံတားသုံးစင်း လိုတာမို့ အဆင်ပြေပါတယ်။ မြို့နှစ်ဆယ်ဆိုရင်တော့ တံတား ၁၉၀ စင်း လိုလာပြီး peering က non-transitive ဖြစ်လို့ ခရီးသွားတစ်ယောက်က တံတားနှစ်စင်းကို ဆက်တိုက် ဖြတ်ကူးလို့လည်း မရပါဘူး။
Transit Gateway ကတော့ အဲဒီအစား ဗဟို ကားဂိတ်ကြီး တစ်ခုပါ။ မြို့တိုင်းက ကားဂိတ်ဆီ လမ်းတစ်လမ်းစီ ဖောက်ပြီး ကားဂိတ်ရဲ့ အချိန်ဇယားတွေ — သူ့ route table တွေ — က မြို့တစ်မြို့ချင်းစီ ဘယ်နေရာတွေကို သွားခွင့်ရှိလဲ ဆုံးဖြတ်ပါတယ်။ Prod နဲ့ dev နှစ်ခုလုံးက shared-services မြို့ကို ရောက်နိုင်ပေမဲ့ အချင်းချင်းကိုတော့ ဘယ်တော့မှ မရောက်နိုင်ပါဘူး။
ကားဂိတ်အတွက် ချိတ်ထားတဲ့ လမ်းတစ်လမ်းစီကို နာရီအလိုက်နဲ့ ဖြတ်သွားတဲ့ ပမာဏကို gigabyte အလိုက် ပေးရတာမို့ အခမဲ့ မဟုတ်ပေမဲ့ run ရတာကတော့ အများကြီး ပိုရိုးရှင်းပါတယ်။
Problem → Why → Solution
ပြဿနာ: peering mesh
AWS Fundamentals မှာ VPC နှစ်ခုကို peer လုပ်ပြီး ဘက်တစ်ဖက်စီမှာ route တစ်ကြောင်းစီ ထည့်ခဲ့ပါတယ်။ အခု organization မှာ shared-services VPC၊ egress VPC နဲ့ အများအားဖြင့် အချင်းချင်းကိုပါ ရောက်ဖို့လိုတဲ့ VPC ဆယ်ခု ရှိလာပါပြီ။ VPC n ခုရဲ့ full mesh က peering connection n(n-1)/2 ခု လိုပါတယ် — VPC ဆယ်ခုအတွက် ၄၅ ခု၊ အပြင် route entry အနည်းဆုံး ၉၀၊ VPC တစ်ခုမှာ route table အများကြီးရှိရင် ဒီထက်ပိုပါတယ်။
VPC အသစ်တစ်ခုတိုးတိုင်း တခြား VPC အားလုံးရဲ့ route table တွေကို ပြင်ရပြီး peering က non-transitive ဖြစ်လို့ အားလုံးကို ဗဟို VPC တစ်ခုနဲ့ peer လုပ်ပြီး အဲဒီက traffic ကို forward လုပ်ခိုင်းလို့လည်း မရပါဘူး။ ပိုင်ဆိုင်မှုကလည်း မရှင်းပါဘူး — ကိုယ်မပိုင်တဲ့ account နှစ်ခုကြားက peering request ကို ဘယ် team က approve လုပ်ရမှာလဲ။
def full_mesh(n):
"""Peering connections needed so every VPC reaches every other VPC."""
return n * (n - 1) // 2
print(f"{'VPCs':>5} {'peerings':>9} {'routes':>7} {'TGW attachments':>16}")
for n in (3, 5, 10, 20, 50):
links = full_mesh(n)
# each peering needs a route on both sides (one route table per VPC)
print(f"{n:>5} {links:>9} {2 * links:>7} {n:>16}")ဘာကြောင့် ပြိုကွဲသွားရတာလဲ
Hub က linear ကြီးထွားတဲ့အချိန်မှာ peering က quadratic ကြီးထွားပါတယ် — VPC ၅၀ ဆိုရင် peering ၁,၂၂၅ ခုနဲ့ route ၂,၄၅၀ လိုပေမဲ့ Transit Gateway attachment ၅၀ ပဲ လိုပါတယ်။ Peering မှာ VPC တစ်ခုချင်းအတွက် active connection quota လည်း ရှိပြီး ပြောင်းလဲမှုတိုင်းက account အများကြီးကို ထိခိုက်တာမို့ mesh က technical ပြဿနာ မဖြစ်ခင် အတော်ကြာကတည်းက ညှိနှိုင်းရေး ပြဿနာ ဖြစ်လာပါတယ်။
အဓိက concept: attachment၊ association၊ propagation
- Transit Gateway (TGW)
- Network တွေကို attach လုပ်ရတဲ့ regional၊ highly available router တစ်ခုပါ။ VPC route table တွေနဲ့ သီးခြားဖြစ်တဲ့ ကိုယ်ပိုင် route table တွေအတိုင်း attachment တွေကြား traffic ကို forward လုပ်ပေးပါတယ်။
Attachment ဆိုတာ hub ထဲကို ထိုးထားတဲ့ ဘယ်အရာမဆိုပါ — VPC၊ Site-to-Site VPN၊ Direct Connect gateway၊ SD-WAN appliance တွေအတွက် Connect attachment ဒါမှမဟုတ် တခြား Transit Gateway တစ်ခုဆီ peering attachment။ VPC attachment တစ်ခုက ကိုယ်ရွေးတဲ့ AZ တစ်ခုစီရဲ့ subnet တစ်ခုထဲမှာ ENI တစ်ခုစီ ထားပြီး attachment မှာ subnet ရှိတဲ့ AZ တွေကနေပဲ resource တွေက TGW ကို သုံးနိုင်ပါတယ်။ ဒါကြောင့် team တွေက AZ တိုင်းမှာ သေးငယ်တဲ့ /28 attachment subnet သီးသန့်တွေ ဆောက်ကြတာပါ။
Traffic က layer နှစ်ခုလုံးမှာ route လိုပါတယ်။ VPC route table က destination ကို TGW ဆီ ပို့ရမယ် (ဥပမာ 10.0.0.0/8 ကို tgw-... ဆီ)၊ TGW route table ကလည်း destination ကို ဘယ် attachment ပိုင်လဲ သိရပါမယ်။ ဘက်တစ်ဖက်ဖက်ကို မေ့သွားတာက attachment အသစ် အလုပ်မလုပ်ရတဲ့ အဖြစ်အများဆုံး အကြောင်းရင်းပါ။
| Term | ဖြေပေးတဲ့ မေးခွန်း | စည်းမျဉ်း |
|---|---|---|
| Association | ဒီ attachment ကနေ ဝင်လာတဲ့ traffic အတွက် ဘယ် TGW route table ကို သုံးမလဲ။ | Attachment တစ်ခုကို table တစ်ခုတည်း |
| Propagation | ဘယ် TGW route table တွေက ဒီ attachment ရဲ့ route တွေကို အလိုအလျောက် သိမလဲ။ | Table သုည၊ တစ်ခု ဒါမှမဟုတ် အများကြီး |
| Static route | ဘယ်သူမှ propagate မလုပ်တဲ့ prefix တစ်ခု ဘယ်ကို သွားမလဲ။ | Peering attachment နဲ့ default route တွေအတွက် လိုအပ် |
Segmentation က အဲဒီ ခလုတ်နှစ်ခုကနေ သဘာဝအတိုင်း ထွက်လာပါတယ်။ Prod၊ dev နဲ့ shared services ကို ကိုယ်ပိုင် route table တစ်ခုစီ ပေးပါ။ Prod attachment တွေက prod-rt နဲ့ associate လုပ်ပြီး prod-rt က prod နဲ့ shared ဆီကပဲ propagation ရပါတယ်။ Dev လည်း အဲဒီအတိုင်းပါပဲ။ Shared table ကတော့ အားလုံးဆီက propagation ရတာမို့ shared services က နှစ်ဖက်လုံးကို ပြန်ဖြေနိုင်ပါတယ်။ Prod နဲ့ dev က အချင်းချင်းရဲ့ route တွေကို ဘယ်တော့မှ မမြင်ရတာကြောင့် hub ထဲ နှစ်ခုလုံး ထိုးထားပေမဲ့ သူတို့ကြား traffic ကို hub မှာတင် drop လုပ်လိုက်ပါတယ်။
Segmentation ခိုင်မာဖို့အတွက် TGW ကို ဆောက်တဲ့အခါ default route table association နဲ့ propagation ကို ပိတ်ထားပါ။ မဟုတ်ရင် attachment အသစ်တိုင်းက အရာအားလုံးကို ရောက်နိုင်တဲ့ flat table တစ်ခုထဲ ရောက်သွားပါလိမ့်မယ်။
SEGMENTED HUB-AND-SPOKE
-----------------------
prod VPC dev VPC shared VPC
10.16.0.0/19 10.20.0.0/19 10.24.0.0/19
| | |
[attach] [attach] [attach]
| | |
+------+-------------------+-------------------+------+
| TRANSIT GATEWAY |
| prod-rt assoc: prod learns: prod, shared |
| dev-rt assoc: dev learns: dev, shared |
| shared-rt assoc: shared learns: prod, dev |
+-----------------------------------------------------+
prod <-> shared: OK dev <-> shared: OK prod <-> dev: NO ROUTE- VPC route က prefix ကို TGW ဆီပို့
- Association က TGW table ကို ရွေး
- Propagation က table ကို ဖြည့်
- Table ထဲ route မရှိ = drop
Association ကို 'ဒီ attachment ကနေ traffic ရောက်လာရင် route ကို ဘယ်မှာ ရှာမလဲ'၊ propagation ကို 'ဒီ attachment အကြောင်း ဘယ်သူတွေ သိခွင့်ရှိလဲ' လို့ ဖတ်ကြည့်ပါ။
လက်တွေ့ ဥပမာ: TGW တစ်ခုပေါ်မှာ prod၊ dev နဲ့ shared
ဒီ script က diagram ထဲက segmented hub ကို ရှိပြီးသား VPC သုံးခုနဲ့ ဆောက်ပါတယ်။ VPC တစ်ခုစီမှာ AZ နှစ်ခုထဲ /28 attachment subnet တစ်ခုစီ ရှိပါတယ်။ Default table တွေကို ပိတ်၊ environment တစ်ခုကို route table တစ်ခုစီ ဆောက်၊ association နဲ့ propagation တွေကို ချိတ်ပြီး နောက်ဆုံးမှာ VPC ဘက်က route တွေကို ထည့်ပါတယ်။ TGW ကို ပိုင်မယ့် network account ကနေ run ပါ။
# 1. The hub: no default association/propagation, so nothing is flat
OPTS="AmazonSideAsn=64512,AutoAcceptSharedAttachments=enable"
OPTS="$OPTS,DefaultRouteTableAssociation=disable"
OPTS="$OPTS,DefaultRouteTablePropagation=disable,DnsSupport=enable"
TGW_ID=$(aws ec2 create-transit-gateway --description "core hub" \
--options "$OPTS" --query 'TransitGateway.TransitGatewayId' --output text)
# ...wait until the TGW state is "available" (a few minutes)
# 2. One attachment per VPC, using the /28 attachment subnets in 2 AZs
attach() {
aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id $TGW_ID --vpc-id "$1" --subnet-ids "$2" "$3" \
--query 'TransitGatewayVpcAttachment.TransitGatewayAttachmentId' \
--output text
}
PROD_ATT=$(attach vpc-0a1b2c3d4e5f60001 subnet-0a1b2c3d4e5f6a001 subnet-0a1b2c3d4e5f6b001)
DEV_ATT=$(attach vpc-0a1b2c3d4e5f60002 subnet-0a1b2c3d4e5f6a002 subnet-0a1b2c3d4e5f6b002)
SHR_ATT=$(attach vpc-0a1b2c3d4e5f60003 subnet-0a1b2c3d4e5f6a003 subnet-0a1b2c3d4e5f6b003)
# 3. One TGW route table per environment
new_rt() {
aws ec2 create-transit-gateway-route-table --transit-gateway-id $TGW_ID \
--query 'TransitGatewayRouteTable.TransitGatewayRouteTableId' --output text
}
RT_PROD=$(new_rt); RT_DEV=$(new_rt); RT_SHR=$(new_rt)
# 4. Association: which table each attachment's traffic uses
associate() {
aws ec2 associate-transit-gateway-route-table \
--transit-gateway-route-table-id "$1" --transit-gateway-attachment-id "$2"
}
associate $RT_PROD $PROD_ATT
associate $RT_DEV $DEV_ATT
associate $RT_SHR $SHR_ATT
# 5. Propagation: who learns whose CIDR (prod and dev never learn each other)
propagate() {
aws ec2 enable-transit-gateway-route-table-propagation \
--transit-gateway-route-table-id "$1" --transit-gateway-attachment-id "$2"
}
propagate $RT_PROD $PROD_ATT; propagate $RT_PROD $SHR_ATT
propagate $RT_DEV $DEV_ATT; propagate $RT_DEV $SHR_ATT
propagate $RT_SHR $PROD_ATT; propagate $RT_SHR $DEV_ATT
# 6. VPC side: send the rest of 10.0.0.0/8 to the hub (one per route table)
aws ec2 create-route --route-table-id rtb-0a1b2c3d4e5f6c001 \
--destination-cidr-block 10.0.0.0/8 --transit-gateway-id $TGW_ID
# 7. Check what dev can reach
aws ec2 search-transit-gateway-routes --transit-gateway-route-table-id $RT_DEV \
--filters Name=state,Values=active \
--query 'Routes[].[DestinationCidrBlock,Type,State]' --output tableCode ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်
- Disable the defaults
OPTS="$OPTS,DefaultRouteTableAssociation=disable"Default တွေ ဖွင့်ထားရင် attachment တိုင်းက shared table တစ်ခုတည်းနဲ့ associate လုပ်ပြီး အဲဒီထဲ propagate လုပ်တာမို့ prod က dev ကို ရောက်နိုင်တဲ့ flat network ဖြစ်သွားပါတယ်။ ပိတ်ထားလိုက်ရင် attachment တိုင်းကို ရည်ရွယ်ချက်ရှိရှိ နေရာချရပါတယ်။
- Attachment subnets
--subnet-ids "$2" "$3"AZ တစ်ခုကို subnet တစ်ခုစီပါ။ TGW က တစ်ခုစီထဲမှာ ENI တစ်ခုစီ ထားပြီး ဒီမှာ ပါတဲ့ AZ တွေကပဲ hub ကနေ traffic ပို့နိုင်တာမို့ workload တွေ သုံးတဲ့ AZ တိုင်းကို ထည့်ပါ။
- Association
associate $RT_DEV $DEV_ATTDev VPC ကနေ ရောက်လာတဲ့ traffic ကို dev-rt ထဲမှာ ရှာပါတယ်။ Attachment တစ်ခုကို တစ်ကြိမ်မှာ route table တစ်ခုတည်းနဲ့ပဲ associate လုပ်လို့ ရပါတယ်။
- Propagation
propagate $RT_DEV $SHR_ATTShared VPC ရဲ့ CIDR ကို dev-rt ထဲ အလိုအလျောက် ထည့်ပေးပါတယ်။ PROD_ATT ကို RT_DEV ထဲ propagate လုပ်တဲ့ line မရှိတာကြောင့် dev-rt မှာ prod ဆီ route မရှိဘဲ အဲဒီ traffic ကို drop လုပ်ပါတယ်။
- VPC-side route
--destination-cidr-block 10.0.0.0/8 --transit-gateway-id $TGW_IDဒါမရှိရင် instance တွေက traffic ကို TGW ဆီ ဘယ်တော့မှ မပေးပါဘူး။ Supernet တစ်ခုလုံးကို သုံးတာက VPC route table တွေကို မပြောင်းလဲဘဲ ထားပေးပြီး တကယ့် filtering ကို TGW route table တွေက လုပ်ပါတယ်။
နောက်ဆုံး command ရဲ့ sample output (dev-rt မှာ dev နဲ့ shared ပဲ ရှိပြီး prod မပါပါ):
------------------------------------------
| SearchTransitGatewayRoutes |
+---------------+--------------+---------+
| 10.20.0.0/19 | propagated | active |
| 10.24.0.0/19 | propagated | active |
+---------------+--------------+---------+- Dev instance က 10.24.0.5 ဆီ ပို့
- VPC route 10.0.0.0/8 -> TGW
- TGW က dev-rt ကို ရှာ (association)
- 10.24.0.0/19 (propagated) နဲ့ ကိုက်လား
Destination က shared VPC ထဲမှာ
Forwarded via shared attachment
Destination က prod VPC ထဲမှာ
No route in dev-rt: dropped
Account တွေကြား share လုပ်ခြင်းနဲ့ Region တွေကြား peer လုပ်ခြင်း
TGW တစ်ခုက account တစ်ခုနဲ့ Region တစ်ခုထဲမှာ နေပါတယ်။ Workload account တွေက ကိုယ့် VPC ကို ကိုယ်တိုင် attach လုပ်နိုင်အောင် AWS RAM နဲ့ share လုပ်ပါ — အကောင်းဆုံးကတော့ organization တစ်ခုလုံးကို share လုပ်တာပါ။ AutoAcceptSharedAttachments ဖွင့်ထားရင် member account တွေက attachment တွေဟာ manual accept မလိုဘဲ active ဖြစ်လာပေမဲ့ association ဒါမှမဟုတ် propagation မရှိသေးတာကြောင့် ဘယ်သူ ဘာကို ရောက်နိုင်လဲဆိုတာကို network account က ဆက်ထိန်းချုပ်ထားနိုင်ပါတယ်။
Region တွေကို ချိတ်ဖို့ TGW နှစ်ခုကြား peering attachment တစ်ခု ဆောက်ပါ။ Traffic က AWS backbone ပေါ်မှာပဲ ရှိပြီး encrypt လုပ်ထားပေမဲ့ peering attachment တွေက route တွေကို dynamic propagate မလုပ်တာကြောင့် ဘက်တစ်ဖက်စီမှာ အဝေးက Region ရဲ့ supernet အတွက် static route တွေ ထည့်ရပါတယ်။ Region တစ်ခုစီကို သန့်ရှင်းတဲ့ summary block တစ်ခုစီ ပေးသင့်တဲ့ နောက်ထပ် အကြောင်းရင်းတစ်ခုပါ။
# Share the TGW with every account in the organization
aws ram create-resource-share --name core-tgw \
--resource-arns arn:aws:ec2:us-east-1:111122223333:transit-gateway/$TGW_ID \
--principals arn:aws:organizations::111122223333:organization/o-a1b2c3d4e5 \
--no-allow-external-principals
# Peer with the hub in eu-west-1 (same account here; can be cross-account)
PEER_ATT=$(aws ec2 create-transit-gateway-peering-attachment \
--transit-gateway-id $TGW_ID \
--peer-transit-gateway-id tgw-0f1e2d3c4b5a69788 \
--peer-account-id 111122223333 --peer-region eu-west-1 \
--query 'TransitGatewayPeeringAttachment.TransitGatewayAttachmentId' \
--output text)
# The peer side accepts in its own Region
aws ec2 accept-transit-gateway-peering-attachment --region eu-west-1 \
--transit-gateway-attachment-id $PEER_ATT
# Peering attachments need static routes: send Europe's /12 across
aws ec2 create-transit-gateway-route \
--transit-gateway-route-table-id $RT_SHR \
--destination-cidr-block 10.32.0.0/12 \
--transit-gateway-attachment-id $PEER_ATTအဲဒီ hub ကိုပဲ code အဖြစ်
CDK မှာ high-level Transit Gateway construct မရှိတာကြောင့် production stack တွေက L1 Cfn class တွေကို တိုက်ရိုက်သုံးကြပါတယ်။ ပုံစံက CLI version နဲ့ အတူတူပါပဲ — default ပိတ်ထားတဲ့ TGW၊ သီးသန့် subnet တွေပေါ်က attachment၊ association နဲ့ propagation ပါတဲ့ route table တစ်ခု၊ attachment အရင်ရှိနေမှ ဆောက်ရမယ့် VPC route တွေ။
import { App, Stack } from "aws-cdk-lib";
import * as ec2 from "aws-cdk-lib/aws-ec2";
const app = new App();
const stack = new Stack(app, "TgwHubStack");
const tgw = new ec2.CfnTransitGateway(stack, "Tgw", {
description: "core hub",
amazonSideAsn: 64512,
autoAcceptSharedAttachments: "enable",
defaultRouteTableAssociation: "disable",
defaultRouteTablePropagation: "disable",
});
const vpc = new ec2.Vpc(stack, "ProdVpc", {
ipAddresses: ec2.IpAddresses.cidr("10.16.0.0/19"),
maxAzs: 2,
natGateways: 0,
subnetConfiguration: [
{ name: "app", subnetType: ec2.SubnetType.PRIVATE_ISOLATED, cidrMask: 22 },
{ name: "tgw", subnetType: ec2.SubnetType.PRIVATE_ISOLATED, cidrMask: 28 },
],
});
const attachment = new ec2.CfnTransitGatewayVpcAttachment(stack, "ProdAttach", {
transitGatewayId: tgw.ref,
vpcId: vpc.vpcId,
subnetIds: vpc.selectSubnets({ subnetGroupName: "tgw" }).subnetIds,
});
const prodRt = new ec2.CfnTransitGatewayRouteTable(stack, "ProdRt", {
transitGatewayId: tgw.ref,
});
new ec2.CfnTransitGatewayRouteTableAssociation(stack, "ProdAssoc", {
transitGatewayAttachmentId: attachment.ref,
transitGatewayRouteTableId: prodRt.ref,
});
new ec2.CfnTransitGatewayRouteTablePropagation(stack, "ProdProp", {
transitGatewayAttachmentId: attachment.ref,
transitGatewayRouteTableId: prodRt.ref,
});
// VPC side: app subnets send the rest of 10.0.0.0/8 to the hub
vpc.selectSubnets({ subnetGroupName: "app" }).subnets.forEach((subnet, i) => {
const route = new ec2.CfnRoute(stack, "AppToTgw" + i, {
routeTableId: subnet.routeTable.routeTableId,
destinationCidrBlock: "10.0.0.0/8",
transitGatewayId: tgw.ref,
});
route.addDependency(attachment); // the TGW must be attached first
});
app.synth();Production မှာ
Production မှာ တကယ်လုပ်ပုံ
Organization အများစုက Region တစ်ခုကို TGW တစ်ခုစီကို သီးသန့် network account ထဲမှာ run ပြီး RAM နဲ့ share လုပ်ကြပါတယ်။ Account အသစ်တွေက account vending ကနေ VPC attach ပြီးသားနဲ့ ထွက်လာပြီး automation တစ်ခု (အများအားဖြင့် env=prod လို tag ကို ဖတ်တဲ့ EventBridge rule နဲ့ Lambda function) က attachment ကို မှန်ကန်တဲ့ route table နဲ့ associate လုပ်ပြီး မှန်ကန်တဲ့ propagation တွေကို enable လုပ်ပေးပါတယ်။ TGW route table တွေကို လူက လက်နဲ့ ပြင်တာ ရှားပါတယ်။
Pattern နှစ်ခုကို နေရာတိုင်းနီးပါးမှာ တွေ့ရပါတယ်။ Centralized egress က NAT Gateway တွေကို egress VPC တစ်ခုထဲမှာ ထားပြီး spoke route table တွေက အဲဒီ attachment ဆီ static 0.0.0.0/0 route ရတာမို့ NAT Gateway ဒါဇင်ချီအစား အနည်းငယ်ပဲ run ရပါတယ်။ Centralized inspection ကတော့ traffic ကို AWS Network Firewall run နေတဲ့ inspection VPC ကနေ ဖြတ်ပို့ပါတယ်။ အဲဒီ attachment မှာ appliance mode ဖွင့်ထားဖို့ လိုပြီး flow တစ်ခုရဲ့ ဦးတည်ရာ နှစ်ဖက်လုံးက AZ တစ်ခုတည်းကို သုံးလို့ stateful firewall က စကားဝိုင်းတစ်ခုလုံးကို မြင်ရပါတယ်။
Cost model က ဒီ design တွေကို ပုံဖော်ပါတယ် — attachment-hour အလိုက်နဲ့ TGW ထဲ ပို့တဲ့ GB အလိုက် ပေးရပါတယ်။ Replication traffic terabyte ဆယ်ချီ ဖလှယ်တဲ့ VPC နှစ်ခုကို peering မှာ hourly charge နဲ့ data processing fee မရှိတာကြောင့် TGW နဲ့အတူ တိုက်ရိုက် peering connection တစ်ခုနဲ့ ချိတ်ထားလေ့ရှိပါတယ်။ Region အများကြီးနဲ့ ရှုပ်ထွေးတဲ့ policy တွေအတွက်ဆိုရင် team တွေက global policy document တစ်ခုနဲ့ အဲဒီ idea တွေပေါ်မှာပဲ တည်ဆောက်ထားတဲ့ AWS Cloud WAN ကို စဉ်းစားကြပါတယ်။
အမှားများ
အဖြစ်များတဲ့ အမှားတွေ
အမှား ၁: default route table ကို ဖွင့်ထားခဲ့တာ
Default တွေက attachment တိုင်းကို table တစ်ခုတည်းထဲ associate နဲ့ propagate လုပ်တာကြောင့် dev VPC တစ်ခု attach လုပ်လိုက်တာနဲ့ production database တွေကို ရောက်နိုင်သွားပါတယ်။ Team တွေက ဒါကို setup လုပ်တုန်း မဟုတ်ဘဲ audit လုပ်တဲ့အချိန်မှ သိကြပါတယ်။ TGW ကို default နှစ်ခုလုံး ပိတ်ပြီး ဆောက်ပါ၊ အနည်းဆုံး attachment တိုင်းကို traffic မသယ်ခင် default table ထဲက ရွှေ့ထုတ်ပါ။
အမှား ၂: ဦးတည်ရာ တစ်ဖက်တည်းကိုပဲ route လုပ်တာ
dev-rt မှာ shared route ရှိနေပေမဲ့ dev ကနေ shared ကို ping လုပ်တာ timeout ဖြစ်နေပါတယ်။ ပုံမှန် အကြောင်းရင်းက ပြန်လာတဲ့ လမ်းကြောင်းပါ — shared-rt မှာ dev attachment ဆီက propagation မရှိတာ ဒါမှမဟုတ် shared VPC ရဲ့ route table မှာ TGW ဆီ ပြန်သွားတဲ့ route မရှိတာပါ။ နေရာလေးခုကို အမြဲစစ်ပါ — VPC route table နှစ်ခုနဲ့ TGW route table နှစ်ခု။
အမှား ၃: attachment subnet မှာ AZ တစ်ခု ကျန်ခဲ့တာ
Attachment မှာ AZ နှစ်ခုထဲက subnet တွေပဲ ရှိရင် တတိယ AZ ထဲက instance တွေက hub ကို လုံးဝ မသုံးနိုင်တာကြောင့် ကြုံရာကျပန်း၊ တစ်စိတ်တစ်ပိုင်း outage လို ထင်ရပါတယ်။ VPC သုံးတဲ့ AZ တိုင်းမှာ attachment subnet တစ်ခုစီ ထည့်ပါ။
Best Practices
Best practice များ
- TGW ကို network account ထဲမှာ ပိုင်ပြီး RAM နဲ့ share လုပ်ကာ association နဲ့ propagation ကို tag ကနေ automate လုပ်ပါ။
- AZ တိုင်းမှာ ကိုယ်ပိုင် route table ပါတဲ့ /28 attachment subnet သီးသန့်တွေ သုံးပါ။
- VPC route တွေကို supernet တွေနဲ့ TGW ဆီ ညွှန်ပြီး filtering ကို TGW route table တွေကို လုပ်ခိုင်းပါ။
- ဘယ်တော့မှ မရောက်သင့်တဲ့ range တွေအတွက် blackhole route တွေ ထည့်ထားပါ၊ ဒါဆို propagation မှားသွားရင်တောင် ပွင့်မသွားပါဘူး။
💰 Cost & Cleanup
Transit Gateway ကို attachment တစ်ခုစီ (VPC၊ VPN ဒါမှမဟုတ် peering attachment တစ်ခုစီ) အတွက် နာရီအလိုက်နဲ့ သူ့ထဲပို့တဲ့ data GB အလိုက် charge လုပ်တာကြောင့် ဒီ lab ထဲက attachment သုံးခုက traffic မရှိရင်တောင် ရှိနေတဲ့ နာရီတိုင်း ပိုက်ဆံကုန်ပါတယ်။ RAM sharing ကိုယ်တိုင်ကတော့ အခမဲ့ပါ။ Inter-Region peering က inter-Region data transfer ကိုလည်း ထပ်ပေါင်းပါတယ်။ Transit Gateway အတွက် free tier မရှိတာကြောင့် lab ပြီးတာနဲ့ attachment၊ route table နဲ့ TGW ကို ချက်ချင်းဖျက်ပါ၊ လက်ရှိ rate တွေကို Transit Gateway pricing page မှာ စစ်ကြည့်ပါ။
စမ်းပြီးရင် ဖျက်ဖို့ command
# VPC-side routes first, then attachments, route tables and the TGW
aws ec2 delete-route --route-table-id rtb-0a1b2c3d4e5f6c001 \
--destination-cidr-block 10.0.0.0/8
for ATT in $PROD_ATT $DEV_ATT $SHR_ATT; do
aws ec2 delete-transit-gateway-vpc-attachment \
--transit-gateway-attachment-id $ATT
done
# ...wait until the attachments are "deleted", then:
for RT in $RT_PROD $RT_DEV $RT_SHR; do
aws ec2 delete-transit-gateway-route-table \
--transit-gateway-route-table-id $RT
done
aws ec2 delete-transit-gateway --transit-gateway-id $TGW_IDMini challenge
Mini challenge: centralized egress
Prod နဲ့ dev ကို အချင်းချင်း မရောက်စေဘဲ internet ကို သူ့ကနေ ရောက်နိုင်အောင် egress VPC တစ်ခု (NAT Gateway တွေပါတဲ့ 10.28.0.0/22) ကို hub ထဲ ထည့်ပါ။
- Egress VPC ကို attach လုပ်ပြီး egress-rt အသစ်တစ်ခုနဲ့ associate လုပ်ပါ
- prod-rt နဲ့ dev-rt မှာ egress attachment ဆီ static 0.0.0.0/0 route တစ်ခု ထည့်ပါ
- ပြန်လာတဲ့ traffic လမ်းရှာတွေ့အောင် prod နဲ့ dev ကို egress-rt ထဲ propagate လုပ်ပါ
ရလဒ်: dev-rt ပေါ်မှာ search-transit-gateway-routes run ရင် 10.20.0.0/19 နဲ့ 10.24.0.0/19 က propagated၊ 0.0.0.0/0 က static အဖြစ် ပြပြီး 10.16.0.0/19 အတွက်တော့ ဘာမှ ဆက်မရှိပါဘူး။
အရိပ်အမြွက် ကြည့်ရန်
egress-rt က prod နဲ့ dev ကို သိပေမဲ့ prod-rt နဲ့ dev-rt က egress ဆီ default route တစ်ခုပဲ ရပြီး အချင်းချင်းရဲ့ CIDR တွေကို မရပါဘူး။ Egress VPC ထဲမှာလည်း NAT subnet တွေက 10.0.0.0/8 အတွက် TGW ဆီ ပြန်သွားတဲ့ route တွေ လိုပါတယ်။
အဖြေ ကြည့်ရန်
EGR_ATT=$(aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id $TGW_ID --vpc-id vpc-0a1b2c3d4e5f60004 \
--subnet-ids subnet-0a1b2c3d4e5f6a004 subnet-0a1b2c3d4e5f6b004 \
--query 'TransitGatewayVpcAttachment.TransitGatewayAttachmentId' --output text)
RT_EGR=$(aws ec2 create-transit-gateway-route-table --transit-gateway-id $TGW_ID \
--query 'TransitGatewayRouteTable.TransitGatewayRouteTableId' --output text)
aws ec2 associate-transit-gateway-route-table \
--transit-gateway-route-table-id $RT_EGR --transit-gateway-attachment-id $EGR_ATT
# Spokes: default route to egress (static, because nothing propagates 0/0)
for RT in $RT_PROD $RT_DEV; do
aws ec2 create-transit-gateway-route --transit-gateway-route-table-id $RT \
--destination-cidr-block 0.0.0.0/0 --transit-gateway-attachment-id $EGR_ATT
done
# Return path: egress-rt learns prod and dev
for ATT in $PROD_ATT $DEV_ATT; do
aws ec2 enable-transit-gateway-route-table-propagation \
--transit-gateway-route-table-id $RT_EGR --transit-gateway-attachment-id $ATT
doneQuick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
မှတ်ထားရမယ့် အချက်များ
- Full-mesh peering က n(n-1)/2 နှုန်းနဲ့ ကြီးထွားပြီး non-transitive ဖြစ်ပါတယ်၊ Transit Gateway ကတော့ network တစ်ခုကို attachment တစ်ခုပဲ တိုးပါတယ်။
- Traffic က TGW ဆီ VPC route တစ်ခုနဲ့ destination attachment ဆီ TGW route တစ်ခု လိုပါတယ်။
- Association က ဝင်လာတဲ့ traffic အတွက် table ကို ရွေးပြီး propagation က network တစ်ခုရဲ့ route တွေကို ဘယ်သူ သိမလဲ ဆုံးဖြတ်ပါတယ်။
- Prod၊ dev နဲ့ shared ကို ခွဲထားဖို့ default route table ကို ပိတ်ပါ။
- RAM နဲ့ share လုပ်၊ Region တွေကို static route နဲ့ peer လုပ်ပြီး ရိုးရှင်းတဲ့ volume များ VPC တစ်စုံအတွက် peering ကို ဆက်သုံးပါ။
What is AWS Transit Gateway? — AWS Documentation
Transit gateway route tables — AWS Documentation
AWS Transit Gateway pricing — AWS Documentation