https:\/\/docs.aws.amazon.com\/ja_jp\/vpc\/latest\/tgw\/transit-gateway-quotas.html<\/a><\/p>\n\n\n\nCIDR \u304c\u7570\u306a\u308c\u3070\uff12\u3064\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u3092\u30eb\u30fc\u30c8\u306b\u767b\u9332\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u5197\u9577\u5316\u304c\u76ee\u7684\u3060\u3063\u305f\u306e\u3067\u7570\u306a\u308b CIDR \u3067\u767b\u9332\u3059\u308b\u306e\u306f\u3061\u3087\u3063\u3068\u9055\u3046\u306a\u3068\u601d\u3044\u3001AWS \u30b5\u30dd\u30fc\u30c8\u306b\u76f8\u8ac7\u3057\u307e\u3057\u305f\u3002\u5197\u9577\u5316\u3059\u308b\u305f\u3081\u306e\u89e3\u6c7a\u7b56\u306f\u4e0b\u8a18\uff12\u3064\u3068\u3044\u3046\u3053\u3068\u3060\u3063\u305f\u306e\u3067\u3001\u307e\u305a\u306f \u2460 \u306e\u65b9\u6cd5\u3092\u691c\u8a3c\u3057\u3066\u307f\u307e\u3057\u305f\u3002
\u3000\u3000\u2460 \u81ea\u5206\u3067\u969c\u5bb3\u691c\u77e5\u306e\u4ed5\u7d44\u307f\u3092\u69cb\u7bc9\u3057\u3001ReplaceTransitGatewayRoute API\u3092\u4f7f\u3063\u3066 CIDR \u5b9b\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u3092\u5207\u308a\u66ff\u3048\u308b
\u3000\u3000\u2461 \u30b9\u30bf\u30c6\u30a3\u30c3\u30af\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8ae6\u3081\u3066\u3001\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u3059\u308b<\/p>\n\n\n\n
\u969c\u5bb3\u6642\u306b CIDR \u5b9b\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u3092\u5207\u308a\u66ff\u3048\u308b<\/h2>\n\n\n\nVPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u3092\u5207\u308a\u66ff\u3048\u308b\u4ed5\u7d44\u307f<\/h3>\n\n\n\n
\u969c\u5bb3\u691c\u77e5\u306e\u4ed5\u7d44\u307f\u306f CloudWatch \u30a2\u30e9\u30fc\u30e0\u3092\u4f7f\u7528\u3057\u3001VPN \u306e TunnelState < 1 \u306b\u306a\u3063\u305f\u3089 Lambda \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002Lambda \u3067\u306f\u969c\u5bb3\u524d\uff08\u5de6\u4e0b\u56f3\uff09\u304b\u3089\u969c\u5bb3\u5f8c\uff08\u53f3\u4e0b\u56f3\uff09\u306b\u5207\u308a\u66ff\u3048\u308b\u305f\u3081\u306b\u3001\u4e0b\u8a18\u306e2\u3064\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002
\u3000\u3000a) ReplaceTransitGatewayRoute API \u306b\u3088\u308a\u3001\u30eb\u30fc\u30c8\u30c6\u30fc\u30d6\u30eb\uff08TGW_RTB_VPC\uff09\u306e\u30eb\u30fc\u30c8\u3092\uff11\u3064\u76ee\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u304b\u3089\uff12\u3064\u76ee\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u3078\u5909\u66f4
\u3000\u3000b) disassociate_transit_gateway_route_table API \u3068 associate_transit_gateway_route_table API\u306b\u3088\u308a\u3001\u30eb\u30fc\u30c8\u30c6\u30fc\u30d6\u30eb\uff08TGW_RTB_VPN\uff09\u304b\u3089\uff11\u3064\u76ee\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u306e\u95a2\u9023\u4ed8\u3051\u3092\u524a\u9664\u3057\u3001\uff12\u3064\u76ee\u306e VPN \u30a2\u30bf\u30c3\u30c1\u30e1\u30f3\u30c8\u306e\u95a2\u9023\u4ed8\u3051\u3092\u8ffd\u52a0<\/p>\n\n\n\n
<\/figure><\/li>
<\/figure><\/li><\/ul><\/figure>\n\n\n\nLambda \u3092\u4f5c\u3063\u3066\u307f\u308b<\/h3>\n\n\n\n
\u5b9f\u969b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4e0b\u8a18\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n
import json\nimport boto3\n\nVPN_CIDR = '192.168.0.0\/24'\nTGW_RTB_VPC = 'tgw-rtb-06xxxxxxxxxxxxxxx'\nTGW_RTB_VPN = 'tgw-rtb-0axxxxxxxxxxxxxxx'\nTGW_VPN1 = 'tgw-attach-06xxxxxxxxxxxxxxx'\nTGW_VPN2 = 'tgw-attach-08xxxxxxxxxxxxxxx'\n\ndef lambda_handler(event, context):\n\n print(\"---VPN tunnel down!---\")\n \n client = boto3.client('ec2')\n\n# << change route table >>\n query = client.replace_transit_gateway_route(\n DestinationCidrBlock=VPN_CIDR,\n TransitGatewayRouteTableId=TGW_RTB_VPC,\n TransitGatewayAttachmentId=TGW_VPN2\n )\n\n# << disassociate route table >>\n query = client.disassociate_transit_gateway_route_table(\n TransitGatewayRouteTableId=TGW_RTB_VPN,\n TransitGatewayAttachmentId=TGW_VPN1\n )\n\n# << associate route table >>\n query = client.associate_transit_gateway_route_table(\n TransitGatewayRouteTableId=TGW_RTB_VPN,\n TransitGatewayAttachmentId=TGW_VPN2\n )<\/code><\/pre>\n\n\n\n\u691c\u8a3c\u7d50\u679c\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002
Lambda \u5b9f\u884c\u524d\u306f\u4e0b\u8a18\u753b\u50cf\u306e\u901a\u308a\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u30eb\u30fc\u30c8\u306b\u306f VPN 1 \u304c\u6307\u5b9a\u3055\u308c\u3001\u95a2\u9023\u4ed8\u3051\u3082 VPN1 \u304c\u7d10\u3065\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n
<\/figure><\/li>
<\/figure><\/li><\/ul><\/figure>\n\n\n\n\u30a2\u30e9\u30fc\u30e0\u3092\u30c8\u30ea\u30ac\u30fc\u306b Lambda \u304c\u5b9f\u884c\u3055\u308c\u308b\u3068\u30eb\u30fc\u30c8\u306f VPN2 \u306b\u5909\u66f4\u3055\u308c\u3001\u95a2\u9023\u4ed8\u3051\u3082 VPN1 \u306e\u524a\u9664\u3068 VPN2 \u306e\u8ffd\u52a0\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n
<\/figure><\/li>
<\/figure><\/li><\/ul><\/figure>\n\n\n\nCloudWatch \u30a2\u30e9\u30fc\u30e0\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u306f\u8a18\u8f09\u3092\u7701\u304d\u307e\u3059\u304c\u3001\u3053\u306e\u3088\u3046\u306a\u624b\u9806\u306b\u3088\u308a\u30b9\u30bf\u30c6\u30a3\u30c3\u30af\u30eb\u30fc\u30c8\u3067\u3082\u5197\u9577\u5316\u69cb\u6210\u304c\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n
\u3055\u3044\u3054\u306b<\/h2>\n\n\n\n
\u3053\u3053\u307e\u3067\u691c\u8a3c\u3057\u307e\u3057\u305f\u304c\u3001CloudWatch \u30a2\u30e9\u30fc\u30e0\u304c\u30a2\u30e9\u30fc\u30e0\u72b6\u614b\u3092\u691c\u77e5\u3059\u308b\u307e\u3067\u306b1\u5206\u307b\u3069\u304b\u304b\u308b\u305f\u3081\u3001\u3082\u3046\u5c11\u3057\u77ed\u3044\u6642\u9593\u3067\u5207\u308a\u66ff\u3048\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u3001\u6700\u7d42\u7684\u306b\u306f\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3067\u69cb\u7bc9\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f(^^;<\/p>\n","protected":false},"excerpt":{"rendered":"
\u3053\u3093\u306b\u3061\u306f\u3001\u7c73\u9808\u3067\u3059\u3002\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304d Transit Gateway \u30cd\u30bf\u3067\u3059\u3002 \u691c\u8a0e\u3057\u3066\u3044\u305f\u69cb\u6210 \u5143\u3005\u3001\u5de6\u4e0b\u56f3\u306e\u3088\u3046\u306b\uff12\u53f0\u306e\u30eb\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u30b5\u30a4\u30c8\u9593 VPN \u3092\u5197\u9577\u5316\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u4eca\u56de\u3001\u5197\u9577\u5316\u69cb\u6210\u3068\u3044\u3046\u70b9\u306f\u305d\u306e\u307e\u307e\u3067\u3001T […]<\/p>\n","protected":false},"author":2,"featured_media":4606,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[42],"_links":{"self":[{"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4641"}],"collection":[{"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=4641"}],"version-history":[{"count":8,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4641\/revisions"}],"predecessor-version":[{"id":4665,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4641\/revisions\/4665"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/media\/4606"}],"wp:attachment":[{"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=4641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=4641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ryucom.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=4641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}