ããã«ã¡ã¯ãã¯ã©ã¦ãã¤ã³ãã°ã¬ã¼ã·ã§ã³2é¨ æè¡1課 宮形 ã§ãã
AWS ã® Application Load Balancer (以ä¸ALB) ã§ã¯ãALBã®é ç½®å ã¨ã«ã¼ãã£ã³ã°å ã®EC2ã¤ã³ã¹ã¿ã³ã¹ã¯åä¸VPCã¨ããæ§æãä¸è¬çã§ãããå®ã¯ALBã¨EC2ã¤ã³ã¹ã¿ã³ã¹ãç°ãªããªã¼ã¸ã§ã³ã»ç°ãªãVPCã¨ããæ§æãå¯è½ã«ãªã£ã¦ãã¾ããALBã§ã®è² è·åæ£ã»åé·åããã«ããªã¼ã¸ã§ã³ã§è¡ããã¨ãã§ãã¾ãã
æ¬BLOGã§ã¯è¨å®æ¹æ³ããç´¹ä»ããã¦ããã ãã¾ãã
æ§æå³ã¨æ¦è¦
æ§æå³ã¨ãã¦ã¯ä¸è¨ã®ããã«ãªãã¾ãã
VPCéã®æ¥ç¶ã« Transit Gateway ãå©ç¨ãã¾ãããALB ãã EC2 ã¸çéã§ããã°ããã®ã§ãVPCãã¢ãªã³ã°ãSite-to-Site VPN ã§ãå¯è½ã§ããALBã¨EC2ãé ç½®ããæ±äº¬ãªã¼ã¸ã§ã³ããã¡ã¤ã³ãªã¼ã¸ã§ã³ããEC2ã®ã¿é ç½®ãããã¼ã¸ãã¢åé¨ãããµããªã¼ã¸ã§ã³ãã¨ãã¾ããã
å®ã¯ãã¨ã㨠AWS Global Accelerator ã®å©ç¨ãæ¤è¨ãã¦ããã®ã§ããã調æ»ããã¨ã¤ã³ã¿ã¼ãããæ¥ç¶ãå¿ é ã¨ãããã¾ããããã©ã¤ãã¼ãæ¥ç¶(ã¤ã³ã¿ã¼ãããéå ¬é)ãè¡ããã±ã¼ã¹ããããã¨ã¨ããã§ã« Transit Gateway ãæ§ç¯æ¸ã§ãã£ããã¨ãããALB ã§å®ç¾ãããã¨ã«ãã¾ããã
ã¡ãªãã
ä¸è¨ã¡ãªãããããã¨èãã¦ãã¾ãã
- EC2å©ç¨æãå®ä¾¡ãªãµããªã¼ã¸ã§ã³ãé¸æãããã¨ã§ã®ã³ã¹ãåæ¸
- EC2ã«ã¹ãããã¤ã³ã¹ã¿ã³ã¹ãå©ç¨ããéã®ã¤ã³ã¹ã¿ã³ã¹ä¸æ対çï¼ãã«ããªã¼ã¸ã§ã³ã¨ãããã¨ã§å ¨å°ãåæã«åæ¢ãããªã¹ã¯ãé¿ããï¼
注æããªãã¦ã¯ãªããªãã®ã¯ãã³ã¹ãåæ¸ã主ãªç®çã§ãããã¡ã¤ã³ãªã¼ã¸ã§ã³å ¨ä½é害æã®ãã£ã¶ã¹ã¿ãªã«ããª(DR)ã¨ãã¦ã¯é©åã§ã¯ãªããã¨ã§ããALBãã¡ã¤ã³ãªã¼ã¸ã§ã³ã®ã¿ã®åä¸é害ç¹ã§ããããã§ããã¡ã¤ã³ãªã¼ã¸ã§ã³å ¨ä½é害対çã®å ´åã¯ããµããªã¼ã¸ã§ã³ã«ã ALB ãé ç½®ã Route 53 ãã§ã¤ã«ãªã¼ãã¼ã«ã¼ãã£ã³ã°ãçµã¿åãããçãé©åã§ãã
è¨å®æ¹æ³
VPCãEC2ãTransit GatewayãALB ã®è¨å®æ¹æ³ã«ã¤ãã¦ã¯ããã§ã«å¼ç¤¾ããã°ãä¸è¬ãµã¤ãã«å¤ã æ å ±ãããã¨æãã®ã§ãå²æãããã¾ãã
å EC2ã¤ã³ã¹ã¿ã³ã¹ ã® Security Group è¨å®
åEC2ã¤ã³ã¹ã¿ã³ã¹ã¯ãALBããã®ã«ã¼ãã£ã³ã°ãè¡ãããã Security Group ã¤ã³ãã¦ã³ãã«ã¼ã«ã¯é©å®éæ¾ãã¦ããã¾ãã
ãµããªã¼ã¸ã§ã³å´ã¯VPCãç°ãªãã®ã§ã¤ã³ãã¦ã³ãã«ã¼ã«ã®ã½ã¼ã¹ã Security Group ãé¸æã§ãã¾ãããã¡ã¤ã³ãªã¼ã¸ã§ã³å´ã®CIDRãããã¯ã§è¨å®ãã¾ãã
ã¿ã¼ã²ããã°ã«ã¼ãã¨ALBã®è¨å®
è¨å®ä½æ¥ã¯ã¡ã¤ã³ãªã¼ã¸ã§ã³å´ã®AWSããã¼ã¸ã¡ã³ãã³ã³ã½ã¼ã«ããè¡ãã¾ããæ¬ä¾ã§ã¯æ±äº¬ãªã¼ã¸ã§ã³ã¨ãªãã¾ãã
VPCã³ã³ã½ã¼ã«ããããã¿ã¼ã²ããã°ã«ã¼ãã-ãã¿ã¼ã²ããã°ã«ã¼ãã®ä½æããé¸æãã¾ãã
æåã®ç»é¢ã®ãã¿ã¼ã²ããã¿ã¤ãã®é¸æãã§ã¯ãIPã¢ãã¬ã¹ããé¸æãã¾ãã
æåã®ç»é¢ã®æ®ãã®è¨å®ã¯ãé常㮠ALB è¨å®æã¨åãã§ãããVPCã㯠ALB ãé ç½®ããã¡ã¤ã³ãªã¼ã¸ã§ã³ã®VPC-IDã¨ãã¾ãã
ãã«ã¹ãã§ãã¯ã é常㮠ALB è¨å®æã¨åãã§ããã次ã¸ããé¸æãã¾ãã
次ã®ç»é¢ãIPã¢ãã¬ã¹ãã§ã¯ãã¹ããã1ã®ãããã¯ã¼ã¯ã« ALB ãé ç½®ããã¡ã¤ã³ãªã¼ã¸ã§ã³ã®VPC-IDãé¸æãã¾ãã ã¹ããã2ã® IPv4ã¢ãã¬ã¹ã«ã¡ã¤ã³ãªã¼ã¸ã§ã³ã«é ç½®ããEC2ã¤ã³ã¹ã¿ã³ã¹ã®ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ãæå®ãããä¿çä¸ã¨ãã¦ä»¥ä¸ãå«ããããé¸æãã¾ãã
ç¶ãã¦åãç»é¢ã§ã¹ããã1ã®ãããã¯ã¼ã¯ã«ããã®ä»ã®ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ããé¸æãã¾ãã ã¹ããã2ã® IPv4ã¢ãã¬ã¹ã«ãµããªã¼ã¸ã§ã³ã«é ç½®ããEC2ã¤ã³ã¹ã¿ã³ã¹ã®ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ãæå®ãããä¿çä¸ã¨ãã¦ä»¥ä¸ãå«ããããé¸æãã¾ãã
ç»é¢ãä¸ã¸ã¹ã¯ãã¼ã«ãã¦ãã¿ã¼ã²ããã確èªãã¸é²ãã¾ããæ¬ä¾ã§ã¯ã¿ã¼ã²ããä¸è¦§ã«ã¡ã¤ã³ãªã¼ã¸ã§ã³ã®EC2ã¤ã³ã¹ã¿ã³ã¹2å°(ã¾ã¼ã³=ap-northeast-1)ããµããªã¼ã¸ã§ã³ã®EC2ã¤ã³ã¹ã¿ã³ã¹2å°(ã¾ã¼ã³=ãã¹ã¦)ã®è¨4å°ã表示ããã¦ãããã¨ã確èªãã¾ãããã¿ã¼ã²ããã°ã«ã¼ãã®ä½æããé¸æãã¦ãè¨å®ãå®äºãã¾ãã
ç¶ãã¦ããã¼ããã©ã³ãµã¼ãã®ç»é¢ãããä»ã»ã©è¨å®ããã¿ã¼ã²ããã°ã«ã¼ããALBã®ã«ã¼ãã£ã³ã°å ã¨ãã¦å²ãå½ã¦ãã¾ãã
ã¿ã¼ã²ããã°ã«ã¼ãã®ãã¿ã¼ã²ãããã¿ãã®ç»é¢ããããã¹ã¦ã®EC2ã¤ã³ã¹ã¿ã³ã¹ã®ãã«ã¹ãã§ãã¯ã healthy ã«ãªã£ã¦ãããã¨ã確èªãã¾ãã
以ä¸ã§ã¿ã¼ã²ããã°ã«ã¼ãã¨ALBã®è¨å®ä½æ¥ã¯å®äºã§ãã
åä½ç¢ºèª
Webãã©ã¦ã¶ããALBã¸ã¢ã¯ã»ã¹ãã¾ããç¡äºWebãµã¤ãã表示ããã¾ããåãªã¼ã¸ã§ã³ã®ã©ã®EC2ã¤ã³ã¹ã¿ã³ã¹ã«æ¥ç¶ãã¦ããããããããWebãã¼ã¸ãé ç½®ãã¦ããã¨ãF5ãã¼çã§ç»é¢æ´æ°ã«ãããã¦ã©ã¦ã³ãããã³ã§é çªã«ç°ãªããªã¼ã¸ã§ã³ã®EC2ã¸ã«ã¼ãã£ã³ã°ããã¦ãããã¨ããããã¾ãã
ã¡ã¤ã³ãªã¼ã¸ã§ã³ã®EC2ã¤ã³ã¹ã¿ã³ã¹2å°ããã¹ã¦åæ¢ãã¾ããããWebãµã¤ãã¯ãµããªã¼ã¸ã§ã³ã®ã¿ã§è¡¨ç¤ºã§ãã¦ãããã¨ããããã¾ãã
éã«ãµããªã¼ã¸ã§ã³ã®EC2ã¤ã³ã¹ã¿ã³ã¹2å°ããã¹ã¦åæ¢ãã¾ãããWebãµã¤ãã¯ã¡ã¤ã³ãªã¼ã¸ã§ã³ã®ã¿ã§è¡¨ç¤ºã§ãã¦ãããã¨ããããã¾ãã
ç¡äºãæå¾ ããåä½ã¨ãªããã¨ã確èªã§ãã¾ããã
注æç¹
ç°ãªããªã¼ã¸ã§ã³éæ¥ç¶ã®ãã¼ã¿è»¢éæé
æ¬ä¾ã§ã¯ ç°ãªããªã¼ã¸ã§ã³éã®VPCæ¥ç¶ã« Transit Gateway ãå©ç¨ãã¦ããããã¼ã¿è»¢éæéããããã¾ããã¯ã©ã¤ã¢ã³ããµã¼ãã¼éã®éä¿¡ãã¼ã¿éãå¤ãã·ã¹ãã ã§ã¯ããã®ç¹ãã³ã¹ãå¢ã«ãªããªããã注è¦ããå¿ è¦ãããã¾ãã
ã¹ãããã¤ã³ã¹ã¿ã³ã¹ä¸ææã®å¯¾å¿
EC2ã«ã¹ãããã¤ã³ã¹ã¿ã³ã¹ãå©ç¨ãã¦ããå ´åãä¸æããæã®ããã©ã«ãåä½ããã¤ã³ã¹ã¿ã³ã¹çµäºãã¨ãªã£ã¦ãã¾ãã ãã®å¾ã«EC2ã®èµ·å(ï¼åä½æ)ãè¡ãã¨æ®ã©ã®å ´åãã©ã¤ãã¼ãIPã¢ãã¬ã¹ãå¤ãã£ã¦ãã¾ãã®ã§ãã¿ã¼ã²ããã°ã«ã¼ãã®è¨å®å¯¾å¿ãå¿ è¦ã§ãã
è¨å®ã«ããã¹ãããã¤ã³ã¹ã¿ã³ã¹ä¸ææã®åä½ããä¼æ¢ãã«å¤ãã¦ããã¨ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ãä¿æãããã®ã§ãæ¤è¨ããã¨ããã§ãããã
åèï¼ ä¸æãã ã¹ãããã¤ã³ã¹ã¿ã³ã¹ ã®ä¼æ¢ - Amazon Elastic Compute Cloud
ã¾ã¨ã
ALB ã®ã¿ã¼ã²ããã°ã«ã¼ããã¤ã³ã¹ã¿ã³ã¹ã§ã¯ãªãIPã¢ãã¬ã¹ã¨ãããã¨ã§ãALBã§ã®EC2ã®è² è·åæ£ã»åé·åããã«ããªã¼ã¸ã§ã³ã§è¡ããã¨ãåºæ¥ã¾ãããã³ã¹ããæããªãããµã¼ãã¹ã®å¯ç¨æ§ãé«ãããå ´åã«æ¤è¨ã§ããæ§æã§ã¯ãªãã§ããããã
æ¬BLOGãçæ§ã®ãå½¹ã«ãã¦ã°å¹¸ãã§ãã
宮形ç´å¹³(å·çè¨äºã®ä¸è¦§)
ã¨ã³ã¿ã¼ãã©ã¤ãºã¯ã©ã¦ãé¨ ã½ãªã¥ã¼ã·ã§ã³ã¢ã¼ããã¯ã1課
好ããªãé ã¯ç¼¶ãã¥ã¼ãã¤ã¨æ¬æ ¼ç¼é