Python
Elastic Beanstalkã«ã¯Serverç°å¢ã¨ããä¸ã¤ãWorkerç°å¢ããããããããããªãã®ã§èª¿ã¹ã¦ã¿ããã¤ãã§ã«ä½¿ã£ã¦ã¿ãã Amazon Elastic Beanstalk Workerç°å¢ã¨ã¯ å®äºããã¾ã§ã«é·ãæéãããããªãã¬ã¼ã·ã§ã³ã¾ãã¯ã¯ã¼ã¯ããã¼ãå®è¡ããå ´åããããã®â¦
ä¸è¨ã¨åãããã«Elastic Beanstalkã§ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ã使ã£ã¦Webãµã¼ãç°å¢ãæ§ç¯ãã¦ããã¾ãããµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ã¨å®è¡ç°å¢ãPythonã«å¤ããã ãã§ãããã(â©Â´âï½)â© amegaeru.hatenablog.jp ããã㨠Elastic Beanstalkã®Serverç°å¢ãPytâ¦
Pythonååã§Webãµã¼ãç°å¢ãä½æãããã¨ãã§ããã¨é¢¨ã®ãããã§èããã®ã§è©¦ãã¦ã¿ã(´Ïï½) ããã㨠ãã¼ã«ã«ç°å¢ã§Pythonã®æ©è½ã使ãWebãµã¼ãã¨ãã¦å®è¡ãã ç°å¢ Windows11{ Python } å®è·µ ï¼ï¼Webãµã¼ãèµ·å ï¼ï¼ï¼ï¼ä¸è¨ã³ãã³ããå®è¡ > python3 -â¦
ã¨ããããåãã°ãããã§ä½ã£ã¦ããããã°ã©ã ã§ãããã¡ããã¨ããã±ã¼ã¸ç®¡çããã»ããããã¨æãå§ããã®ã§(é ã)ãPythonã§ä»®æ³ç°å¢ãå°å ¥ãã¦ã¿ãã ããã㨠Windows11å ã«Pythonã®ä»®æ³ç°å¢ãä½æãã å®è·µï¼ ï¼ï¼ä»®æ³ç°å¢ä½æ ï¼ï¼ï¼ï¼ä»®æ³ç°å¢ç¨ãâ¦
Amazon Elastic Beanstalkã®Workerç°å¢ãæ§ç¯ããéã«ãWebAPIããã°ã©ã ãä½æããå¿ è¦ããã£ãã®ã§Pythonã§ç°¡åã«WebAPIãä½æã§ããã¨åã®FastAPIã使ã£ã¦ã¿ãã â»èª¿ã¹ã¦ã¿ããFastAPIãElastic Beanstalkã®Workerç°å¢ã«é©ç¨ããã®ã¯å°ãããããããå¿ è¦â¦
第1åã§ã¯GETã¯ã§ããããã«ãªã£ãã®ã§POSTãDELETEããã£ã¦ã¿ãã amegaeru.hatenablog.jp ãããããã ã¡ã½ãããä½æããã°ãã話ã§ã¯ãªããããã (´Ðï½ã) âåé¡ç¹ ãã©ã¦ã¶ã®URLããæããããHTTPãªã¯ã¨ã¹ãã¯GETã®ã¿ã®ããåãURLã§ã¯ã¡ã½ããã«ããâ¦
Web API(API Gateway(HTTP API)+Lambda)ã®ä»çµã¿ã§DynamoDBãæä½ããä»çµã¿ãä½ã£ã¦ã¿ãã ããã㨠é©å½ãªWindows端æ«ããcurlã³ãã³ããæã¡ãAPI Gateway(HTTP API)ããããã¯ã¨ã³ãã®Lambda(Python)ãDynamoDBã«æ¥ç¶ãæä½ããã â»curlã³ãã³ãã¯äºåã«â¦
ãã©ã¦ã¶ãããããããªæä½ãã§ããã¨ä¾¿å©ãªã®ã§è©¦ãã«DynamoDBãæä½ããä»çµã¿ãä½ã£ã¦ã¿ããâ»ã¿ã¤ãã«ãé·ããã âããã㨠ãã©ã¦ã¶ã®URL(https://xxx.com/[resource]?[key]=[value]ã®ãããªå½¢)ã§API Gateway(REST API)ã«æ¥ç¶ããããã¯ã¨ã³ãã®Lambda(â¦
Serverlessã®Webã¢ããªã±ã¼ã·ã§ã³ãä½ããããã«ãªã£ããã¤ã±ã¦ãã¨æã£ãã®ã§ãã£ã¦ã¿ã *1 âããã㨠ã»Lambdaé¢æ°ãä½æ ã»APIGatewayãREST APIã§ä½æ ã»ä½æããAPIGatewayããLambdaé¢æ°ã«æ¥ç¶ âæ§æ âå®è·µï¼ ï¼ï¼Lambdaé¢æ°ä½æ ï¼ã¼ï¼ï¼Lambdaã³ã³ã½â¦
GUIã§ã½ã¡ã½ã¡ããã®ã¯ãã³ã»ã³ã¹ã ã¨ä¸å¸ã«è¨ãããã®ã§Lambdaé¢æ°ä½æãã³ã¼ãåãã¦ã¿ã¾ãã(´âï½)ォェー âããã㨠CloudShellããCLIã§Lambdaé¢æ°ãä½æ(+ IAM Role,Policy) âæ§æ âå®è·µï¼ ï¼ï¼ããªã·ã¼ä½æ # aws iam create-policy --policy-name MyFuncâ¦
æè¿pythonããã¼ã¸ã§ã³ä¸ããéã«[python -V]ã³ãã³ãã§ãã¼ã¸ã§ã³ã表示ãããªããªãããããå°ã£ãã®ã§ãã¼ã¸ã§ã³ã®ç¢ºèªæ¹æ³ã調ã¹ã¦ã¿ãã âWindows11 >python -V Python >python -V Python âAWS CloudShell $ python -V Python 2.7.18 $ python3 -V Pytâ¦
ä»æ¥ã¯Amazon SQSãPythonããæä½ãã¾ãï¼(ï½â¡Â´) âããã㨠CloudShellã§Pythonã®å¯¾è©±ã¢ã¼ãããAmazon SQSãæä½ âå®è·µï¼ 1.ãã¥ã¼ä½æ ã»CloudShellã¸ãã°ã¤ã³ããä¸è¨ãå®è¡ $ python3 -V Python 3.7.16 $ python3 >>> import boto3 >>> queue_name = 'Tâ¦