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

インターンから入社してRailsのメール送信をSengGridに移行してみて

7850a83d81b034248782d63e7dcf7974?s=47 tatsuya
September 08, 2021

 インターンから入社してRailsのメール送信をSengGridに移行してみて

7850a83d81b034248782d63e7dcf7974?s=128

tatsuya

September 08, 2021
Tweet

Transcript

  1. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ Πϯλʔϯ͔Βೖࣾͯ͠
 Railsͷϝʔϧૹ৴ΛSendGrid ʹҠߦͯ͠Έͯ ϥϯαʔζגࣜձࣾ ։ൃ෦/ฏ໺ୡ໵

  2. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ΞδΣϯμ  • ࣗݾ঺հ

    • ϑϥϯεྉཧਓ͔ΒRailsΛษڧ͠ɺۦ͚ग़͠ΤϯδχΞ΁ • MENTAͱͷग़ձ͍ • ϙʔτϑΥϦΦ࡞੒ͷϙΠϯτ • ϥϯαʔζΠϯλʔϯ΁ೖࣾ • Lancers Assistant/Creativeͷ঺հ • ϝʔϧૹ৴ΛSendGrid΁Ҡߦ • ·ͱΊ
  3. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ࣗݾ঺հ

  4. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ࣗݾ঺հ  ฏ໺ ୡ໵(ͻΒͷ

    ͨͭ΍ ) • Lancers৽ଔΤϯδχΞ • ϑϥϯεྉཧਓˠ2020/11ʹΠϯλʔϯ
 ͱͯ͠δϣΠϯɻ4݄͔Βਖ਼ࣾһʹ • Rails੡ͷLCC(LancersCreativeCloud)Λ։ൃ • झຯ: ஋ஈ͸͍͚҆Ͳྉཧ͕ඒຯ͍͠
 ډञ԰Λ୳͢͜ͱ(࠷ۙ͸ࣗॗؾຯɻɻ ) tatuya4451 @44511336tatuya
  5. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ͳͥϑϥϯεྉཧਓ͔Β
 ׬શҟۀछͷΤϯδχΞΛ໨ࢦͨ͠ͷ͔

  6. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁  ಇ͍ͯͨళฮ •

    ϑϥϯεͷҰͭ੕ϨετϥϯʮChartronʯ • େࡕҰͭ੕ʮAgneldorʯ • ϋΠΞοτϦʔδΣʔϯγʔେࡕ ߴߍੜͷ࣌ɺ฼ͱϑϨϯνΛ৯΂ʹ͍͖িܸΛड͚Δɻ
 →⁋ௐཧࢣઐ໳ֶߍ΁ೖֶ • แஸͷ࢖͍ํ͔Βϑϥϯεޠɺௐཧ࣮शΛ௨ͯ͠ϑϨϯνͷجຊΛֶͿ • ଔۀޙɺϑϥϯε΁Ұ೥ཹֶ • ൒೥ؒ͸ϑϥϯεୈೋͷ౎ࢢϦϤϯͷ͓৓Ͱ(ߍࣷ)ͰޠֶɺྉཧΛษڧ • ࢒Γͷ൒೥͸ݱ஍ݚमΛߦ͏ • ؼࠃޙ͸େࡕͷொ৔΍ϗςϧͰݚᮎΛੵΉ
  7. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁  • ౦ژͰग़ళ͢ΔλΠϛϯάͰίϩφ͕ྲྀߦ

    • ͲΜͳ؀ڥͰ΋ࣗ෼Ͱίϯτϩʔϧͯ͠࢓ࣄ͕Ͱ͖Δ 
 ৬छʹ௅ઓ͍ͨ͠ • ࣌ؒͱ৔ॴʹͱΒΘΕͳ͍ಇ͖ํΛ͍ͨ͠ • ҰͭͷεΩϧʹґଘͨ͘͠ͳ͍ స৬Λܾҙ
  8. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁  • ϓϩάϥϛϯάεΫʔϧͰ໿2ϲ݄ษڧ

    • HTM L • CS S • Rub y • Rail s • Javascrip t • ϝϧΧϦͷΫϩʔϯΞϓϦʮFURIMAʯ
 ΛνʔϜͰ੍࡞ 
  9. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁   •

    ΦϯϥΠϯͰษڧ஥͕ؒͰ͖ΔʮLIve-StudyʯΛ੍࡞ • ௨஌ػೳ • DMػೳ • ϑΥϩʔػೳ • ݕࡧػೳ • ܝࣔ൘ػೳ • Slack௨஌ • Πϕϯτͷ։࠵ɺฤूɺ࡟আɺࢀՃɺऴྃ(CRUD ) • ϩʔΧϧͰ։ൃ • ຊ൪؀ڥ͸͸ECSΛ༧ఆ
  10. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ͔͠͠

  11. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ AWSͰϙʔτϑΥϦΦެ։͢Δ
 ํ๏͕Θ͔ΒΜ

  12. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  MENTAͰSREͷ҆ୡ(@adachin0817)͞Μͱग़ձ͍
 ΠϯϑϥͷجૅΛڭ͑ͯ௖͘͜ͱʹ •

    LinuxͰͷίϚϯυͷૢ࡞ • DockerͰͷ։ൃ؀ڥͷߏங • AWSͰͷαʔόʔߏங • AnsibleΛར༻ͨ͠ΠϯϑϥίʔυԽ • CircleCIͰͷϦϦʔεࣗಈԽ ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁
  13. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁ ։ൃ؀ڥߏ੒ਤ •

    ։ൃ؀ڥ͸DockerΛ࠾༻ • nginxͱunicornΛϦόʔεϓϩΩγ • supervisorͰىಈ͢ΔϓϩηεΛ؅ཧ

  14. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  ϑϥϯεྉཧਓ͔Βۦ͚ग़͠ΤϯδχΞ΁ ຊ൪؀ڥߏ੒ਤ •

    ຊ൪αʔόʔ͸AWS/EC 2 • ߏ੒؅ཧ͸AnsibleΛ࠾༻ • CircleCIͰࣗಈσϓϩΠ • SSLԽ͸Let`sEncrypt ALB΍RDSΛ࢖༻͔͕ͨͬͨ͠
 ίετ࡟ݮͷͨΊ࠷খݶͷߏ੒Ͱӡ༻
  15. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ϙʔτϑΥϦΦ࡞੒ͷϙΠϯτ

  16. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϙʔτϑΥϦΦ࡞੒ͷϙΠϯτ  • όάͷͳ͍ΞϓϦέʔγϣϯΛ࡞Δ

    • ׬੒౓ > ೉͍͠ػೳɺڽͬͨσβΠϯ • ࢖༻ٕज़ͷબఆཧ༝Λઆ໌Ͱ͖Δ • ࠷৽ͷٕज़ΛऔΓೖΕͯ΋ཧ༝͕આ໌Ͱ͖ͳ͍ͱ୯७ʹٕज़͕࢖͍͍ͨਓͳͷ͔ͳͱ
 ࢥΘΕͯ͠·͏ • ݱ৔Ͱ͸՝୊ʹଇٕͨ͠ज़બఆΛ͢Δඞཁ͕͋Δ
 • ࢤ๬ઌͷٕज़ελοΫʹ߹ΘͤΔ • Πϯϑϥ໘Ͱ͸ͳΔ΂͘ίετΛ཈͑ͨΠϯϑϥઃܭΛ͢Δ΂͖(݄/2000~3000ԁ ) • ౰࣌ࣗ෼͸ECS/FargateͰӡ༻ֶ͔͕ͨͬͨ͠शίετ(ӡ༻ίετ΋)͕ߴ࣮͗ͯ͢૷Ͱ͖ͳ͔ͬͨ
 

  17. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ϥϯαʔζ΁Πϯλʔϯͱͯ͠ೖࣾ

  18. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϥϯαʔζ΁Πϯλʔϯͱͯ͠ೖࣾ 

  19. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  LancersCreativeCloud→AWS ECS/Fargate •

    Ruby 2.7. 1 • Rails 6.0. 3 • Jque y • AW S • ECS/Fargat e • Docke r • CircleC I • DATADO G • SendGrid ϥϯαʔζ΁Πϯλʔϯͱͯ͠ೖࣾ
  20. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  • ෳࡶͳόονॲཧͷ࣮૷͔Βద༻·Ͱ •

    TerraformΛॻ͖׵͑ͯυϝΠϯΛมߋ • ΫϥΠΞϯτͷϚΠϖʔδ • Docker։ൃ؀ڥͷվળ • DB੔ཧ • CircleCiͷϦϑΝΫλϦϯά • ใु؅ཧػೳ • ϝʔϧαʔόʔΛSendGridʹҠߦ • etc. • SREͷ҆ୡ͞Μ͕͍ۙҐஔʹ͍ΔͷͰΞϓϦέʔγϣϯͷ
 ࣮૷͚ͩͰͳ͘Πϯϑϥ΋΍Βͤͯ௖͘ػձ͕͋ΔͷͰ
 ෯޿͍࣮຿ܦݧ͕Ͱ͖Δ • ΠϯλʔϯͰ΋ࡋྔͷ͋ΔλεΫΛ೚ͯ͠໯͑Δ ϥϯαʔζ΁Πϯλʔϯͱͯ͠ೖࣾ
  21. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ϝʔϧαʔόʔΛSendGrid΁Ҡߦ

  22. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϝʔϧαʔόʔΛSendGridʹҠߦ  ՝୊ (NBJMΞΧ΢ϯτݻ༗ͷ໰୊

     w ଘࡏ͠ͳ͍ϝʔϧΞυϨεʹϝʔϧૹ৴Λ͢ΔͱεύϜೝఆ͞Εϝʔϧૹ৴͕Ұ࣌తʹ 
 ετοϓ͢Δ w Ұ೔ͷϝʔϧૹ৴্ݶ͕ݶΒΕ͍ͯΔ LCC͸ΞϓϦ಺Ͱͷ௨஌ػೳ͕ແ͍ͷͰ
 ϝʔϧ͕ૹ৴͞Εͳ͍ͱΫϥΠΞϯτ͔Βͷ
 ཁ๬Λݟಀͯ͠͠·͏͜ͱ΋ɺɺ
 ݱ৔͔ΒͷΞϥʔτ্͕͕͍ͬͯͨͷͰ
 ૣٸʹରԠ
  23. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϝʔϧαʔόʔΛSendGridʹҠߦ  SMTP API

    ϝϦοτ ϝϦοτ σϝϦοτ σϝϦοτ • ௥੻ػೳʢਖ਼͘͠ૹ৴͞Ε͔ͨ֬ೝͰ͖Δʣ • ෼ੳػೳʢϚʔέςΟϯάʹ׆༻ʣ • ૹ৴཰ͷվળʢSPFɺDKIMͷ׬ᘳͳઃఆʣ • HTTPͰૹ৴͢Δ͜ͱʹΑͬͯrailsΞϓϦଆͷॲཧ͸ϦΫΤετΛ
 ౤͛Δ͚ͩʹͳΔ • ActionMailer͕defalutͰ༻ҙ͍ͯ͠Δ഑৴ํ๏
 Λ࢖͏͜ͱ͸rails wayʹ৐Δ͜ͱͰ͋ΔͷͰ(rails
 ͷ఩ֶͱͯ͜͠Ε͸ॏཁ)ɺ࣮૷ͷखؒ౳͸ল͚Δ • طଘͷActionMailerͱͷڞଘ • RailsαʔόʔଆͰඇಉظॲཧΛ͠ͳ͍ͱ͍͚ͳ͍ • GmailͰૹ৴͍ͯ͠ΔͷͰ্ड़ͨ͠໰୊͕ൃੜ͍ͯ͠Δ
  24. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup  w 4.51͔Β4FOE(SJE"1*΁Ҡߦ w

    "DUJPO.BJMFSͷ֤ϝʔϥʔͷॲཧ͸ͦͷ··ྲྀ༻ w "DUJPO.BJMFSͷ഑৴ํ๏Λ4FOE(SJE"1*༻ʹ৽ͨʹ௥Ճ w طଘͷ֤ϝʔϥʔͰ࡞੒͞ΕͨϝʔϧΦϒδΣΫτ͕࣮ߦ͞ΕͨλΠϛϯάͰ 
 .BJM4FOE(SJEΫϥεΛݺͼग़͠4FOE(SJE༻ͷΦϒδΣΫτʹஔ͖׵͑ w ϝʔϧૹ৴ςετ͸ϞοΫίϯςφΛ༻͍ͯςετ ࣮૷ํ਑ SMTP SendGrid API
  25. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ࣮૷ํ਑  ࣮૷ͷৄࡉ͸ϥϯαʔζͷΤϯδχΞϒϩάʹॻ͍ͯ·͢ͷͰࢀߟʹʂ

  26. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ ϝʔϧૹ৴ςετʹ͍ͭͯ

  27. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ϝʔϧૹ৴ςετʹ͍ͭͯ  • SREۚᖒ͞Μ͕࡞ͬͯ͘ΕͨϞοΫίϯςφͰ


    ϝʔϧૹ৴Λςετ • ϞοΫίϯςφͰ༻ҙͨ͠ϞοΫAPIʹϦΫΤετ
 Λૹ৴(ӈਤͷHTTP3030 ) • sendgrid-devܦ༝Ͱmaildev΁SMTPͰϝʔϧ഑৴ • http://xxx.xxx.xxx.xxx:1080/ɹʹΞΫηε͢Δ͜ͱͰ
 maildev΁ϝʔϧ͕ૹ৴͞Ε͍ͯΔ͜ͱ͕ϒϥ΢β্Ͱ
 ֬ೝͰ͖Δ • ΞϓϦଆͷ࣮૷͸Mail:SendGridΫϥε಺Ͱ؀ڥຖʹ
 API઀ଓઌͷϗετΛऔಘ
  28. 2021/9/8 Πϯλʔϯ͔Βೖࣾͯ͠Railsͷϝʔϧૹ৴ΛSengGridʹҠߦͯ͠Έͯ Ҡߦͯ͠Ͳ͏ͳ͔ͬͨ

  29. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup Ҡߦͯ͠Ͳ͏ͳ͔ͬͨ  • ϝʔϧͷૹ৴਺਺্ݶ͕ͳ͘ͳͬͨͷͰΞϓϦέʔγϣϯͷ֦ுʹ޲͚ͯҰาલਐ

    • ϥϯαʔζຊՈͰ΋SendGridAPIͰૹ৴͍ͯ͠ΔͷͰ஌ݟΛ׆༻Ͱ͖Δ • ௥੻ػೳ(ϝʔϧͷ഑৴ঢ়گΛݟ͑ΔԽ ) • ϝʔϧ΁ͷΧςΰϦʔઃఆ͕Ͱ͖ΔͷͰϚʔέςΟϯάʹ׆༻ • ૹ৴཰ͷվળ(SPFɺDIKMͷ׬ᘳͳઃఆ ) • APIʹΑΔૹ৴(SMTPͰ͸ͳ͘HTTPͰૹ৴Ͱ͖Δ)
  30. 2021/9/8 ʲLancers x SUPER STUDIOʳEngineer Meetup ࠷ޙʹ  ϥϯαʔζͰ͸Ұॹʹಇ͍ͯ͘ΕΔΤϯδχΞɺ
 ςοΫϦʔυ(RubyɺPHP)ืू͍ͯ͠·͢ʂ