ããã«ã¡ã¯ð±
æè¡èª²ã®å±±æ¬ã§ãã
11/6 ã®ãã¥ã¼ã¹ã§ CodeBuild 㧠AWS Lambda ã®ã©ã³ã¿ã¤ã ã使ç¨ãããã«ããå¯è½ã«ãªãã¾ããã
ãã¥ã¼ã¹ï¼
AWS CodeBuild 㧠AWS Lambda ã«ããã³ã³ãã¥ã¼ãã£ã³ã°ã®ãµãã¼ããéå§
ããã¥ã¡ã³ãï¼
AWS Lambda compute in AWS CodeBuild - AWS CodeBuild
ä½ãå¬ããã
ãã¾ã¾ã§ã¯ãEC2 ã¾ã㯠ã³ã³ããã¤ã¡ã¼ã¸ ã® 2 æã§ããã
Lambda ãå ãããã¨ã«ãããé¸æè¢ã 3 ã¤ã«ãªã£ã¦ãã¾ãã
å¢ããé¨åï¼
ãã«ã㯠CodeBuild ã®æ示æ¸(buildspec.yml)ã«å¾ã£ã¦è¡ããããLambda é¢æ°ã«ãã«ãå¦çãæ¸ããããã§ã¯ããã¾ããã
å ¬å¼ããã®ãã¥ã¼ã¹ã¨ããã¥ã¡ã³ãã«ã¯ä»¥ä¸ã®è¨è¼ãããã¾ãã
AWS Lambda ã¯ã»ã¼ç¬æã«èµ·åãããããããé«éãªãã«ããå¯è½ã¨ãªãã¾ããã¾ããLambda ã§ã³ã³ãã¥ã¼ãã£ã³ã°ãå®è¡ããã¨ã1 ç§ãããã®ä½¿ç¨éã«å¯¾ãã¦èª²éããããããã³ã¹ããæé©åãããã¨ãã§ãã¾ããCodeBuildã§ã¯ãx86_64 㨠Arm64 ã®ã©ã¡ãã®å½ä»¤ã»ããã¢ã¼ããã¯ãã£ã§ã AWS Lambda ã«ããã³ã³ãã¥ã¼ãã£ã³ã°ãå®è¡ã§ãã¾ãã
AWS CodeBuild 㧠AWS Lambda ã«ããã³ã³ãã¥ã¼ãã£ã³ã°ã®ãµãã¼ããéå§ ãã
AWS Lambda ã³ã³ãã¥ã¼ãã£ã³ã°ã¯ããã«ãã®æé©åãããèµ·åé度ãæä¾ãã¾ããAWS Lambda ã¯ãèµ·åã¬ã¤ãã³ã·ã¼ãçããããããé«éãªãã«ãããµãã¼ããã¾ããAWS Lambda ã¯èªåçã«ã¹ã±ã¼ãªã³ã°ããããããã«ãããã¥ã¼ã§å®è¡ãå¾ æ©ãããã¨ãããã¾ããããã ããAWS Lambda ããµãã¼ããã¦ããªãã¦ã¼ã¹ã±ã¼ã¹ãããã¤ããããããå½±é¿ãããå ´å㯠EC2 ã³ã³ãã¥ã¼ãã£ã³ã°ã使ç¨ãã¦ãã ãã
AWS Lambda compute in AWS CodeBuild - AWS CodeBuild ãã
ä¸è¨ãè¸ã¾ããã¨ãå¬ããç¹ã¯ä»¥ä¸ 3 ã¤ã®ããã§ãã
- Lambda ã¯ç¬æã«èµ·åãããããé«éã«ãã«ããã§ããããã«ãªã
- Lambda ã®å©ç¨æã¯ç§åä½ã®èª²éã«ãªãããã³ã¹ããæé©åã§ãã
- Lambda ã¯èªåçã«ã¹ã±ã¼ã«ããããããã«ãã®åæå®è¡ãç´ æ©ããªã
ããã«ãã®èµ·åãæ©ãï¼å®ãï¼ã¹ã±ã¼ã«ããããï¼ã ã¨ãããã¨ã§ããã
ä»ãå¶ç´ãããã¤ãããã®ã§ãã®ã¡ã»ã©è©³ããè¦ã¦ããã¾ãããã
ãã«ãã®èµ·åãæ©ãï¼
Lambda ã®ã¤ã¡ã¼ã¸ãå©ç¨ããå ´åã«ã¯ãã«ããç¬æã«èµ·åãããæ¤è¨¼ãã¦ã¿ã¾ããã
æ¯è¼ç¨ã«ãEC2 ã Lambda ãDocker ã®ã¤ã¡ã¼ã¸ãå©ç¨ãããã«ãããã¸ã§ã¯ããç¨æãããã«ãå¦çã®å®è¡ã«ã©ã®ç¨åº¦å¦çæéããããã®ãè¦ã¦ã¿ã¾ããã
Lambda ã¯ã©ã³ã¿ã¤ã ã«ããå·®ç°ã確èªãããããgo , java , python ã®ããã¸ã§ã¯ããããããä½ãã¾ããã
ã¾ããå CPU ã¢ã¼ããã¯ãã£(ARM , x86 ) åãããã¸ã§ã¯ããä½ãã¾ããã
ãµã¤ãºã¯åã¤ã¡ã¼ã¸ã®æå°ãµã¤ãºã使ç¨ãã¾ããã
åèããã¥ã¡ã³ãï¼Docker images provided by CodeBuild - AWS CodeBuild
ç¨æããããã¸ã§ã¯ãï¼
ãªããtest-terraform
㯠dockerhub ã«ãã docker ã¤ã¡ã¼ã¸ã使ç¨ãããã«ãããã¸ã§ã¯ãã§ããtest-ec2
ã¯test-ec2-arm
ã®èª¤ãã§ãã
èµ·åã¾ã§ã®æéã測ããããå®éã«ãã«ãã¯ãããæ¥ä»æå»ã¨ã©ã³ã¿ã¤ã ãã¼ã¸ã§ã³ãæ¨æºåºåããã ãã®ç°¡å㪠ãã«ããã¡ã¤ã« (buildspec.yml)ãä½æãã¾ããã å©ç¨ããã¤ã¡ã¼ã¸ã«å¿ãã¦ãã³ã¡ã³ãã¢ã¦ããå¤ãã¦ãPython ã®ã¤ã¡ã¼ã¸ã使ç¨ããéã«ã¯ "python --version" ãå®è¡ããããã«ãã¾ããããªããEC2 ã® Standard ã©ã³ã¿ã¤ã ã®ã¤ã¡ã¼ã¸ã«ã¯åè¨èªãå ¥ã£ã¦ãã¾ãã(terraform以å¤)
- buildspec.yml
version: 1 env: variables: version: "v1" phases: pre_build: commands: - echo pre build #- python --version #- java -version #- go version - terraform -v build: commands: - echo Build started on `date` post_build: commands: - echo Build completed on `date` artifacts: files: artifacts.json
çµè«ã¨ãã¦ãEC2 ãã«ã¹ã¿ã ã¤ã¡ã¼ã¸ ( Docker ) ã«æ¯ã¹ã¦ãLambda ã¯æ©ãã§ãã
å®è¡æé | ç°å¢ã¤ã¡ã¼ã¸ | ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã | CPU | ã©ã³ã¿ã¤ã | ãµã¤ãº | ã¤ã¡ã¼ã¸ |
---|---|---|---|---|---|---|
90 ç§ | EC2 | Amazon Linux | ARM | Standard | 4 GB ã¡ã¢ãªã2 vCPUs | aws/codebuild/amazonlinux2-x86_64-standard:5.0 |
26 ç§ | EC2 | Amazon Linux | x86 | Standard | 3 GB ã¡ã¢ãªã2 vCPUs | aws/codebuild/amazonlinux2-aarch64-standard:3.0 |
8 ç§ | Lambda | Amazon Linux | ARM | GO 1.21 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-aarch64-lambda-standard:go1.21 |
8 ç§ | Lambda | Amazon Linux | x86 | GO 1.21 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-x86_64-lambda-standard:go1.21 |
9 ç§ | Lambda | Amazon Linux | ARM | Amazon Corretto 17 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-aarch64-lambda-standard:corretto17 |
8 ç§ | Lambda | Amazon Linux | x86 | Amazon Corretto 17 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-x86_64-lambda-standard:corretto17 |
8 ç§ | Lambda | Amazon Linux | ARM | Python 3.11 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.11 |
7 ç§ | Lambda | Amazon Linux | x86 | Python 3.11 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-x86_64-lambda-standard:python3.11 |
25 ç§ | ã«ã¹ã¿ã ã¤ã¡ã¼ã¸ (Docker ã¤ã¡ã¼ã¸) | Linux EC2 | x86 | - | 3 GB ã¡ã¢ãªã2 vCPUs | public.ecr.aws/hashicorp/terraform:1.5.0 |
ç¹ã«ãç°å¢ãä½æãããããã¸ã§ãã³ã°(PROVISIONING)ã®é¨åãæ©ãã§ãã
EC2ï¼
Lambdaï¼
Lambda ã«ä½¿ç¨ããã©ã³ã¿ã¤ã (java , go , python)ã CPU ã¢ã¼ããã¯ãã£(x86 , ARM)ã¯ç¹ã«ä½ãå½±é¿ãã¾ããã§ããã
ãç¹ã« java ã¯ã³ã¼ã«ãã¹ã¿ã¼ãã«ãªãããããªããï¼ãã¨ãæ¸å¿µãã¦ããã®ã¯ãææã«çµããã¾ããã
ä½åãã£ã¦ãæ©ãã£ãã§ãã
ãã«ããå®ãï¼
ä¸ã§è©¦ãããã«ãã®æéããæéãã¼ã¸ æé - AWS CodeBuild | AWS ãã試ç®ãã¦ã¿ã¾ãããã
EC2 㨠Lambda ã§æ¯è¼ãã¦ã¿ã¾ãã
EC2 ã®å ´åï¼
ãã«ãæéã¯ãã«ããéä¿¡ãã¦ãããã«ããçµäºããã¾ã§ã®æéã§ãååä½ã§åãä¸ãããã¾ãã
Lambda ã®å ´åï¼
ãã«ãæéã¯ãã«ããéä¿¡ãã¦ãããã«ããçµäºããã¾ã§ã®æéã§ãç§åä½ã§è¨ç®ãããç§åä½ã«åãä¸ãããã¾ãã
ä¸ã®å®è¡çµæã®ãã¡ãä¸ãã 4 ã¤åã®è²»ç¨ãåºãã¦ã¿ã¾ããã
EC2 ã®å ´åã90 ç§ã®å ´å㯠2 åéã®èª²éã¨ãã¦è¨ç®ãã¦ãã¾ãã
Lambda ã®å ´åã8 ç§ã®å ´å㯠9 ç§éã®èª²éã¨ãã¦è¨ç®ãã¦ãã¾ãã
æé | å®è¡æé | ç°å¢ã¤ã¡ã¼ã¸ | ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã | CPU | ã©ã³ã¿ã¤ã | ãµã¤ãº | ã¤ã¡ã¼ã¸ |
---|---|---|---|---|---|---|---|
0.0085 USãã« | 90 ç§ | EC2 | Amazon Linux | ARM | Standard | 4 GB ã¡ã¢ãªã2 vCPUs | aws/codebuild/amazonlinux2-x86_64-standard:5.0 |
0.005 USãã« | 26 ç§ | EC2 | Amazon Linux | x86 | Standard | 3 GB ã¡ã¢ãªã2 vCPUs | aws/codebuild/amazonlinux2-aarch64-standard:3.0 |
0.00009 USãã« | 8 ç§ | Lambda | Amazon Linux | ARM | GO 1.21 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-aarch64-lambda-standard:go1.21 |
0.00018 USãã« | 8 ç§ | Lambda | Amazon Linux | x86 | GO 1.21 | 1 GB ã¡ã¢ãª | aws/codebuild/amazonlinux-x86_64-lambda-standard:go1.21 |
Lambda ã®æ¹ãå®ãã§ããã
å®éã®ä½¿ç¨æã«ã¯ãå®è¡ãããã«ãå¦çã®æéã大ããªã¦ã§ã¤ããå ããããããã«ãæéãå°ãªãå ´å㯠Lambda ã使ã£ã¦åããããã³ã¹ãå¹æã大ããã¨è¨ãã¾ãã
ãããã¸ã§ãã³ã°(PROVISIONING)ã«ãããæéã®å ããå²åã大ããã¨ãã§ããã
ãã«ããã¹ã±ã¼ã«ããããï¼
ãã«ãã®åæå®è¡æ°ã«ã¯å¼ãç¶ãä¸éããã
CodeBuild ã«ã¯ 1 ã¤ã® AWS ã¢ã«ã¦ã³ãã® 1 ã¤ã®ãªã¼ã¸ã§ã³ãã¨ã«åæå®è¡å¯è½ãªãã«ãæ°ã«ä¸éãããã¾ãã
ãã«ãããã¸ã§ã¯ãããã§ã«ããã¤ãåæã«å®è¡ãã¦ããã¨ãã«ãæ°ãããã«ãããã¸ã§ã¯ããå®è¡ã§ããªãï¼ã¨ãããã¨ã§ãã
ããã©ã«ãå¤ãä½ãã®ã§ããã«ããåæã«è¤æ°è¡ãç°å¢ã§ã¯ãä¸éç·©åãããã¨ãå¤ãã§ããä¸éã¯å©ç¨ããã¤ã¡ã¼ã¸ã®ç¨®é¡ã¨ã³ã³ãã¥ã¼ãã£ã³ã°ãµã¤ãºã®çµã¿åããæ¯ã«è¨å®ãããã¾ãã
ã©ã³ã¿ã¤ã ã« Lambda ã使ç¨ããå ´åã«ã¯ä¸éããªãã®ããªï¼ã¨æã£ã¦èª¿ã¹ããã®ã®ãLambda ã®ã©ã³ã¿ã¤ã ãå©ç¨ããå ´åã«ããã«ãã®åæå®è¡æ°ã«ä¸éãããã¾ãã
ç§ã®æ¤è¨¼ç¨ AWS ã¢ã«ã¦ã³ãã®æ±äº¬ãªã¼ã¸ã§ã³ã§ã¯ãæ¦ã 60 ã«ãªã£ã¦ãã¾ãããããã©ã«ãå¤ã¯ 1 ã®ããã§ããå°ãªãã¨æãã¾ãã
Service Quotas ããä¸éãç·©åã§ãã¾ãã®ã§ãå¿
è¦ã«å¿ãã¦å®æ½ãã ããã
Service Quotas ã®ç»é¢ãããLambda ã©ã³ã¿ã¤ã ç¨ã®å¶éå¤ãããã¾ãã
ä¸éæ°ã®æ
å ±ã¯ä»¥ä¸ã®ããã¥ã¡ã³ãããåç
§ãã ããã
Quotas for AWS CodeBuild - AWS CodeBuild
ãã¥ã¼ã使ç¨ãã¦ããªããããã«ãå¦çã®ã¹ã±ã¼ã«ãç´ æ©ãã§ãã
CodeBuild ã«ã¯ãã¥ã¼ã¨ããä»çµã¿ãããã¾ãã
ç¾å¨ã®ãã«ãæ°ãã1 ã¤ã®AWS ã¢ã«ã¦ã³ãã® 1 ã¤ã®ãªã¼ã¸ã§ã³å
ã§åæå®è¡å¯è½ãªãã«ãæ°ã®ä¸éã«éãã¦ããå ´åã«ã¯ããã«ãå¦çã®ãªã¯ã¨ã¹ãããã¥ã¼ã«å
¥ãã¦å¾
ã¤ä»çµã¿ã§ãã
ããã¥ã¼ã¿ã¤ã ã¢ã¦ãããè¨å®ãã¦ããã¨ãä¸å®æéãã¥ã¼ã«å
¥ãã¦å¾
ããããã¨ãã§ãã¾ãã5 åï½8 æéã®éã§è¨å®ã§ãã¾ãã
ãä¸éãè¶
ãã¦ãå¾
ã£ã¦ãããããã«ãã§ãããããã¨ãããã¨ã§ããã
è¨å®ç®æï¼
Lambda ãã©ã³ã¿ã¤ã ã«ããå ´åããã®è¨å®ã¯ããã¾ããã
ç»é¢ï¼
Lambda ã®ã©ã³ã¿ã¤ã ã使ç¨ããå ´åã¯ãããããããã¥ã¼ã使ããªãããã¨ã«ããããã«ãå¦çã®èµ·åãæ©ããã¦ããããã§ãã
以ä¸ã®ã¤ã¡ã¼ã¸ã§ãã
ã©ã³ã¿ã¤ã ã EC2 ã Docker ã³ã³ããã®å ´åï¼
- ãã«ãå¦çã®ãªã¯ã¨ã¹ãããã¥ã¼ã«å ¥ãã
- åæå®è¡å¶éæ°ã«éãã¦ããªãå ´åããã«ãå¦çã®ãªã¯ã¨ã¹ããå¦çãã
- åæå®è¡å¶éæ°ã«éãã¦ããå ´åãããã¥ã¼ã¿ã¤ã ã¢ã¦ããã®è¨å®ãããå ´åã¯ãä¸å®æéãã¥ã¼ã«å ¥ãã¦å¾ ããããè¨å®ããªãå ´åã¯ã¨ã©ã¼ã§çµäºããã
ã©ã³ã¿ã¤ã ã Lambda ã®å ´åï¼
- åæå®è¡å¶éæ°ã«éãã¦ããªãå ´åããã«ãå¦çã®ãªã¯ã¨ã¹ããå¦çãã
- åæå®è¡å¶éæ°ã«éãã¦ããå ´åã¯ã¨ã©ã¼ã§çµäºããã
ããã¥ã¼ã«å
¥ãããã¨ããå¦çãçãããã¨ã«ãããé«éã«ã¹ã±ã¼ã«ã§ããããã§ãã
ãã®åãåæå®è¡ãªã¯ã¨ã¹ãæ°ã®è¶
éæã¯ãè¶
éåãç°å¸¸çµäºããã¨ãããã¨ã§ããã
å¶ç´
ããã¥ã¡ã³ã AWS Lambda compute in AWS CodeBuild - AWS CodeBuild ãã覧ãã ããã
yum ã使ããªããdocker build ã§ããªãã/tmpã¹ãã¬ã¼ã¸ã¯ä½¿ããªãã15 åã§ã¿ã¤ã ã»ã¢ã¦ããããã¨ãã£ãå¶ç´ãããã¾ãã
ã¾ã¨ã
CodeBuild 㧠AWS Lambda ã®ã©ã³ã¿ã¤ã ã使ç¨ãããã«ããå¯è½ã«ãªãã¾ããã
以ä¸ã®ã·ã¼ã³ã§æ´»èºãããã§ããã
- ãã«ããç´ æ©ãèµ·åããã
- ãã«ããå®ãå®è¡ããã
- åæã«å¤ãã®ãã«ããè¡ããã
ãã«ãç°å¢ã®ãããã¸ã§ãã³ã°(PROVISIONING)ã«ãããæéãçããªããã¹ã±ã¼ã«ãæ©ãã®ã§ããçãæéã§çµãããã«ãå¦çãåæã«å¤æ°å®è¡ããããã¨ããå ´é¢ã§å¤§æ´»èºã¨ãªãã§ãããã
ãã ãããã®åãã¥ã¼ã¤ã³ã°ãã§ããªãã®ã§ããæéãããã£ã¦ã確å®ã«ãã«ããããã¨ããå ´é¢ã§ã¯ä¸å©ããããã¾ããã
ä½è«
ééæéã«è¿æã®å±±ãèµ°ã£ã¦ãã¾ãã
æªå¤©åã®å±±ãç¾ãããã®ã§ãã
å±±æ¬ å²ä¹ (è¨äºä¸è¦§)
ã«ã¹ã¿ãã¼ãµã¯ã»ã¹é¨ã®ã¤ã³ãã©ã¨ã³ã¸ãã¢ã
å±±ãèµ°ãã®ã趣å³ã§ãã