Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20221008_JAWSDAYS

 20221008_JAWSDAYS

Takuya Yonezawa

October 08, 2022
Tweet

More Decks by Takuya Yonezawa

Other Decks in Technology

Transcript

  1. ͋Δ͋Δʁͳ&YDFMӡ༻ ൿٕɿ&YDFMਃ੥ॻΛϝʔϧͰૹ৴ʂ γεςϜΦʔόʔϏϡʔ  Excel v2 Excel Excel 4UFQ Ϣʔβͷखݩʹอ؅͞Ε͍ͯΔ

    &YDFMΛར༻ऀͰฤू 4UFQ ਃࠐॻ&YDFMWΛ 
 ΞΧ΢ϯτ؅ཧऀʹૹ෇ 4UFQ ؅ཧऀଆͰอ؅͍ͯ͠Δ 
 &YDFM୆ாʢ௨শਆ&YDFMʣʹసه
  2. ͋Δ͋Δʁͳ&YDFMӡ༻ γεςϜΦʔόʔϏϡʔ  Excel v2 Excel Excel 4UFQ Ϣʔβͷखݩʹอ؅͞Ε͍ͯΔ &YDFMΛར༻ऀͰฤू

    4UFQ ਃࠐॻ&YDFMWΛ 
 ΞΧ΢ϯτ؅ཧऀʹૹ෇ 4UFQ ؅ཧऀଆͰอ؅͍ͯ͠Δ 
 &YDFM୆ாʢ௨শਆ&YDFMʣʹసه సه๨ΕͳͲͷΦϖϛε͕ଟൃɺͭΒ͍😇
  3. ͜͏͍ͨ͠ʂͷਤ γεςϜΦʔόʔϏϡʔ  WEB WEB DB 4UFQ ਃࠐॻ৘ใʹมߋ͕͋ͬͨ৔߹͸ 
 ར༻ऀηϧϑͰ8&#͔Βొ࿥৘ใΛฤू

    ʢར༻ऀೝূ΋ඞཁʣ 4UFQ ؅ཧऀαΠυͰ ར༻ऀͷొ࿥৘ใΛӾཡɾฤू ,FZQPJOU &YDFMΛ׬શఫഇͯ͠%#Խʂ
  4. ϑϧαʔόϨεͰ࣮૷ γεςϜΦʔόʔϏϡʔ  Private subnet VPC AWS Cloud Lambda DynamoDB

    Cognito API-GW API-GW WEB WEB VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda Lambda DB Aurora Serverless V2 RDS Proxy
  5. ֤ίϯϙʔωϯτͷղઆ γεςϜΦʔόʔϏϡʔ  Private subnet VPC AWS Cloud Lambda DynamoDB

    Cognito API-GW API-GW WEB WEB VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda Lambda DB Aurora Serverless V2 RDS Proxy ʲҰ࣌ΞΫηετʔΫϯ؅ཧʳ %ZOBNP%#ͷ55-ػೳΛ༻͍ͯ 
 ར༻ऀͷҰ࣌ΞΫηετʔΫϯΛ؅ཧ 
 ʢ"VSPSBͰτʔΫϯ55-࣮૷͸ॲཧ͕໘౗ɻɻʣ ʲೝূ63-ૹ৴ʳ Ұ࣌ΞΫηετʔΫϯͷ࡞੒͕׬ྃͨ͠Β ར༻ऀʹ8&#ΞΫηε༻ͷೝূ63-Λϝʔϧૹ෇
  6. ֤ίϯϙʔωϯτͷղઆ γεςϜΦʔόʔϏϡʔ  Private subnet VPC AWS Cloud Lambda DynamoDB

    Cognito API-GW API-GW WEB WEB VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda Lambda DB Aurora Serverless V2 RDS Proxy ʲϨίʔυΞΫηε-BNCEBʳ ೝূ63-ܦ༝Ͱجװ%#ͷϨίʔυΛࢀর͢Δࡍʹ͸ ར༻ऀͷτʔΫϯνΣοΫΛ࣮ࢪͷ্ɺ 3%41SPYZܦ༝Ͱجװ%#΁ΞΫηε ʲ71$& (BUFXBZ ʳ τʔΫϯͷόϦσʔγϣϯΛ࣮ࢪ͢ΔͨΊʹ 71$಺͔Β%ZOBNP%#΁ͷΞΫηε͕ ඞཁͱͳΔͨΊɺ(BUFXBZܕ71$&Ͱܦ࿏֬อ
  7. ੺࿮෦෼Λ4".ςϯϓϨʔτͰߏங 4".ͷΧόʔൣғ  Private subnet VPC AWS Cloud Lambda DynamoDB

    Cognito API-GW API-GW WEB WEB VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda Lambda DB Aurora Serverless V2 RDS Proxy
  8. -BNCEB1PXFSUPPMTͷ͋Δੈք  AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: sam-app-jawsdays Globals: Function:

    Timeout: 30 Tracing: Active Api: TracingEnabled: True OpenApiVersion: 3.0.2 Resources: HelloWorldFunction: Type: AWS::Serverless::Function Properties: CodeUri: hello_world/ Handler: app.lambda_handler Runtime: python3.9 Architectures: - x86_64 Layers: - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:33 Events: HelloWorld: Type: Api Properties: Path: /hello Method: get -BNCEBఆٛͷ-BZFSͰ 1PXFSUPPMTͷ-BZFSΛࢦఆ͢Δ͚ͩʂ UFNQMBUFZBNM
  9. -BNCEB1PXFSUPPMTͷ͋Δੈք  import json import uuid from aws_lambda_powertools import Logger

    from aws_lambda_powertools import Tracer from aws_lambda_powertools import Metrics from aws_lambda_powertools.metrics import MetricUnit tracer = Tracer() logger = Logger() metrics = Metrics( namespace="sam-app-jawsdays", service="HelloWorldFunction") @metrics.log_metrics @tracer.capture_lambda_handler @logger.inject_lambda_context(log_event=False) def lambda_handler(event, context): # Powertools Logger logger.info(uuid.uuid4()) # Add Metic metrics.add_metric( name="CallCount", unit=MetricUnit.Count, value=1) # Return Response return None $MPVE8BUDI.FUSJDTΛఆٛ BQQQZ ϝτϦΫεΛ1VTI
  10. -BNCEB1PXFSUPPMTͷ͋Δੈք  import json import uuid from aws_lambda_powertools import Logger

    from aws_lambda_powertools import Tracer from aws_lambda_powertools import Metrics from aws_lambda_powertools.metrics import MetricUnit tracer = Tracer() logger = Logger() metrics = Metrics( namespace="sam-app-jawsdays", service="HelloWorldFunction") @metrics.log_metrics @tracer.capture_lambda_handler @logger.inject_lambda_context(log_event=False) def lambda_handler(event, context): # Powertools Logger logger.info(uuid.uuid4()) # Add Metic metrics.add_metric( name="CallCount", unit=MetricUnit.Count, value=1) # Return Response return None BQQQZ $MPVE8BUDI-PHTΛ +TPOͰߏ଄Խͨ͠ঢ়ଶͰग़ྗ
  11.  !"#$%&%'#()*+,-./ (0121'#3%45 (61789#3%:;<=#8 (>$?@- ("AB,((CD((E((D(((F%3 GHI JK LM NM

    4O#.P (($%Q#:; ((RSTI; ((3"#G=0UV ((WXYZ (([\]1W ((5^; "AB,
  12. վमର৅ͱͳΔ෦෼  Private subnet VPC AWS Cloud Lambda DynamoDB Cognito

    API-GW API-GW WEB WEB VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda Lambda DB Aurora Serverless V2 RDS Proxy 1SJWBUF4VCOFUʹ഑ஔ͍ͯ͠ΔͷͰɺ 4&4ͷΤϯυϙΠϯτͱ௨৴Ͱ͖ͳ͍🥲
  13. ߏங࣌ʹߟ͍͑ͯͨͭͷ௨৴ܦ࿏  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& J1VCMJD4VCOFUˠ*(8 -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1VCMJD4VCOFUʹ഑ஔͨ͠/"5(BUFXBZˠ*(8ͷܦ࿏Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1SJWBUF4VCOFUʹ഑ஔͨ͠*OUFSGBDFܕ71$&ܦ࿏Ͱ

    "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1VCMJD4VCOFU্Ͱ࣮ߦ ύϒϦοΫ*1Λ࣋ͬͨ-BNCEBͷ&/*ܦ༝Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ VPC Public subnet Private subnet Aurora Lambda ENI Internet Gateway AWS Service Internet VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface)
  14. ߏங࣌ʹߟ͍͑ͯͨͭͷ௨৴ܦ࿏  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& J1VCMJD4VCOFUˠ*(8 -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1VCMJD4VCOFUʹ഑ஔͨ͠/"5(BUFXBZˠ*(8ͷܦ࿏Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1SJWBUF4VCOFUʹ഑ஔͨ͠*OUFSGBDFܕ71$&ܦ࿏Ͱ

    "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1VCMJD4VCOFU্Ͱ࣮ߦ ύϒϦοΫ*1Λ࣋ͬͨ-BNCEBͷ&/*ܦ༝Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ VPC Public subnet Private subnet Aurora Lambda ENI Internet Gateway AWS Service Internet VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface) IUUQTEPDTBXTBNB[PODPNKB@KQMBNCEBMBUFTUEHDPO fi HVSBUJPOWQDIUNMWQDDPO fi HVSJOH 1VCMJD4VCOFUͰ-BNCEBΛىಈͯ͠΋ ΠϯλʔωοτΞΫηεͰ͖ͳ͍ʂ
  15. ߏங࣌ʹߟ͍͑ͯͨͭͷ௨৴ܦ࿏  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& J1VCMJD4VCOFUˠ*(8 -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1VCMJD4VCOFUʹ഑ஔͨ͠/"5(BUFXBZˠ*(8ͷܦ࿏Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1SJWBUF4VCOFUʹ഑ஔͨ͠*OUFSGBDFܕ71$&ܦ࿏Ͱ

    "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1VCMJD4VCOFU্Ͱ࣮ߦ ύϒϦοΫ*1Λ࣋ͬͨ-BNCEBͷ&/*ܦ༝Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ VPC Public subnet Private subnet Aurora Lambda ENI Internet Gateway AWS Service Internet VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface) ͦ΋ͦ΋࣮ݱෆՄ ʢυΩϡϝϯτͪΌΜͱಡ΋͏😇ʣ
  16. ֹ݄ྉۚͷࢼࢉΛͯ͠ΈΔ ࣌఺  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& /"5(BUFXBZ࣌ؒ୯Ґྉۚɿ64%IPVS /"5(BUFXBZσʔλॲཧྉɿ64%(# ΠϯλϑΣʔεܕ71$&࣌ؒ୯Ґྉۚɿ64%IPVS ΠϯλϑΣʔεܕ71$&σʔλॲཧྉɿ64%(# ࣌ؒ୯Ґྉۚ

    64%º IPVS º EBZ º "; 64% σʔλॲཧྉ 64%º(#64% ࣌ؒ୯Ґྉۚ 64%º IPVS º EBZ º "; 64% σʔλॲཧྉ 64%º(#64% ໿64% ໿64% VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface)
  17. ֹ݄ྉۚͷࢼࢉΛͯ͠ΈΔ ࣌఺  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& /"5(BUFXBZ࣌ؒ୯Ґྉۚɿ64%IPVS /"5(BUFXBZσʔλॲཧྉɿ64%(# ΠϯλϑΣʔεܕ71$&࣌ؒ୯Ґྉۚɿ64%IPVS ΠϯλϑΣʔεܕ71$&σʔλॲཧྉɿ64%(# ࣌ؒ୯Ґྉۚ

    64%º IPVS º EBZ º "; 64% σʔλॲཧྉ 64%º(#64% ࣌ؒ୯Ґྉۚ 64%º IPVS º EBZ º "; 64% σʔλॲཧྉ 64%º(#64% ໿64% ໿64% VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface) ͏ʔΜɺɺ 71$ͷத͔Β4&4ݺͼग़͢ ܦ࿏֬อͷͨΊ͚ͩʹ͔͋ Πϯϑϥ؅ཧͯ͠Δ$MPVE'PSNBUJPO 
 ςϯϓϨʔτͷमਖ਼΋ඞཁͩΑͳ͋ɻɻ
  18. ߏங࣌ʹߟ͍͑ͯͨͭͷ௨৴ܦ࿏  JJ1SJWBUF4VCOFUˠ/"5(8ˠ*(8 JJJ1SJWBUF4VCOFUˠ71$& J1VCMJD4VCOFUˠ*(8 -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1VCMJD4VCOFUʹ഑ஔͨ͠/"5(BUFXBZˠ*(8ͷܦ࿏Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1SJWBUF4VCOFU্Ͱ࣮ߦ 1SJWBUF4VCOFUʹ഑ஔͨ͠*OUFSGBDFܕ71$&ܦ࿏Ͱ

    "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ -BNCEB͸1VCMJD4VCOFU্Ͱ࣮ߦ ύϒϦοΫ*1Λ࣋ͬͨ-BNCEBͷ&/*ܦ༝Ͱ "84αʔϏεͷΤϯυϙΠϯτͱ௨৴ VPC Public subnet Private subnet Aurora Lambda ENI Internet Gateway AWS Service Internet VPC Public subnet Private subnet Lambda ENI Aurora Internet Gateway NAT Gateway AWS Service Internet VPC Private subnet AWS Service Lambda ENI Aurora VPC Endpoint (Interface) ͦ΋ͦ΋࣮ݱෆՄ ʢυΩϡϝϯτͪΌΜͱಡ΋͏😇ʣ ߴ͍*OUFSOFU௨৴͕ 
 ൃੜ͢ΔͷͰෆ࠾༻ ͪΐͬ͜ͱߴ͍ͷͰෆ࠾༻
  19. VPC Private subnet AWS Service VPC Endpoint (Interface) Lambda ENI

    Route53 Provided DNS VPC Private subnet AWS Service VPC Endpoint (Gateway) Route Table Lambda ENI 71$ΤϯυϙΠϯτ͸छྨ͋Δ  ήʔτ΢ΣΠܕ ΠϯλϑΣʔεܕ ૹ৴ઌ λʔήοτ  MPDBM QMBCD WQDFBCDBCD Ξλονର৅ ར༻ྉۚ ϧʔςΟϯάͷ੍ޚ 
 ର৅αʔϏε αϒωοτຖ ࣌ؒྉۚʴ௨৴ྔ 71$ͷ಺෦%/4 
 ʢ3PVUF1SJWJEFE%/4ʣ ͨ͘͞Μ 71$ ௨৴ྔ͚ͩ 71$ͷϧʔτςʔϒϧ 
 4ͱ%ZOBNP%#͚ͩ
  20. VPC Private subnet AWS Service VPC Endpoint (Interface) Lambda ENI

    Route53 Provided DNS VPC Private subnet AWS Service VPC Endpoint (Gateway) Route Table Lambda ENI 71$ΤϯυϙΠϯτ͸छྨ͋Δ  ήʔτ΢ΣΠܕ ΠϯλϑΣʔεܕ ૹ৴ઌ λʔήοτ  MPDBM QMBCD WQDFBCDBCD Ξλονର৅ ར༻ྉۚ ϧʔςΟϯάͷ੍ޚ 
 ର৅αʔϏε 71$ ௨৴ྔ͚ͩ 71$ͷϧʔτςʔϒϧ 
 4ͱ%ZOBNP%#͚ͩ   (BUFXBZܕ 
 ࣌ؒྉۚෆཁͳͷ͑͑ͳ͋ %ZOBNP%#Ͱ ্ख͍͜ͱͰ͚΁Μ͔ͳʁ αϒωοτຖ ࣌ؒྉۚʴ௨৴ྔ 71$ͷ಺෦%/4 
 ʢ3PVUF1SJWJEFE%/4ʣ ͨ͘͞Μ
  21. %ZOBNP%#4USFBNTͰ΍Δ͜ͱʹͨ͠  %ZOBNP%#4USFBNT  %ZOBNP%#ςʔϒϧͷϨίʔυΠϕϯτʢ*OTFSU .PEJGZ 3FNPWFʣΛΩϟϓνϟͰ͖Δػೳ 4USFBNTͱ-BNCEBؔ਺͸ωΠςΟϒʹ౷߹͞Ε͓ͯΓɺ 
 ϨίʔυΠϕϯτΛτϦΨʹ-BNCEBΛൃՐͰ͖Δ

    %ZOBNP%#Λ#SPLFSͱͯ͠࢖͏͜ͱͰ 
 ΠϕϯτυϦϒϯͳ-BNCEBॲཧΛ࣮ߦͰ͖Δʂ DynamoDB Lambda DynamoDB Streams { "eventName":"INSERT", "dynamodb": { "NewImage" : {...}, "OldImage" : {...} } }
  22. %ZOBNP%#4USFBNTͰ΍Δ͜ͱʹͨ͠  Private subnet VPC AWS Cloud Lambda DynamoDB API-GW

    VPC Endpoint (Gateway) WEB Client WEB Client SES URL Lambda DB Aurora Serverless V2 RDS Proxy #FGPSF
  23. %ZOBNP%#4USFBNTͰ΍Δ͜ͱʹͨ͠  Private subnet VPC AWS Cloud Lambda DynamoDB API-GW

    VPC Endpoint (Gateway) WEB Client WEB Client Lambda SES DynamoDB Streams URL DB Lambda DB Aurora Serverless V2 RDS Proxy DynamoDB ɾϝʔϧ഑৴༻%ZOBNP%#ςʔϒϧ ɾϝʔϧૹ৴ઐ༻-BNCEBΛ৽ઃ { "Mail_Subject":"Mail Subject", "Mail_Body":"Mail Body", "From_Address":"[email protected]", "To_Address":"[email protected]", .... } "GUFS
  24. %ZOBNP%#4USFBNTͰ΍Δ͜ͱʹͨ͠  Private subnet VPC AWS Cloud Lambda DynamoDB API-GW

    VPC Endpoint (Gateway) WEB Client WEB Client Lambda SES DynamoDB Streams URL DB Lambda DB Aurora Serverless V2 RDS Proxy DynamoDB ɾϝʔϧ഑৴༻%ZOBNP%#ςʔϒϧ ɾϝʔϧૹ৴ઐ༻-BNCEBΛ৽ઃ { "Mail_Subject":"Mail Subject", "Mail_Body":"Mail Body", "From_Address":"[email protected]", "To_Address":"[email protected]", .... } "GUFS طଘͷ%ZOBNP%#༻(BUFXBZܕ71$&Λ࠶ར༻͢Δ͜ͱͰɺ ௥ՃͰ/"5΍*OUFSGBDFܕ71$&Λ࡞੒͢Δ͜ͱͳ͘ ϝʔϧૹ৴ػೳ͕࣮ݱͰ͖ͨʂ΍ͬͨͶ😀