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

EC2 using Lumen and DynamoDB and SNS

054312bb8749ab2405c3c5364bc1be1e?s=47 yoppie
June 18, 2019

EC2 using Lumen and DynamoDB and SNS

054312bb8749ab2405c3c5364bc1be1e?s=128

yoppie

June 18, 2019
Tweet

More Decks by yoppie

Other Decks in Technology

Transcript

  1. LumenΛಋೖͨ͠EC2ͱ
 DynamoDBͱSNS

  2. ֓ཁ • খن໛ͷWebΞϓϦέʔγϣϯ • খن໛ͷDB • ϝʔϧૹ৴ • ར༻ݴޠ PHPͱ͍͏റΓ

  3. ٕज़બఆ • AWS EC2, DynamoDB, SNS • ϑϨʔϜϫʔΫ Lumen

  4. Lumen

  5. Lumen • Laravel͕ϕʔεͱͳ͍ͬͯΔ
 ϚΠΫϩϑϨʔϜϫʔΫ • খ͞ͳwebαʔϏε, RESTful API

  6. Laravelͱͷҧ͍ • σΟϨΫτϦߏ੒ • artisanίϚϯυ • Ϩεϙϯεͷ଎͞ • Etc…

  7. Lumen ಋೖ

  8. LumenͱDynamoDB

  9. खॱ 1. laravel-dynamodbΛcomposerͰΠϯετʔϧ
 
 (aws-sdk͕ಋೖ͞ΕΔ) 2. bootstrap/app.phpͷमਖ਼ 3. config/dynamodb.phpͷ࡞੒

  10. ιʔείʔυ

  11. envϑΝΠϧ࡞੒ .env.local .env.dev .env.test .env.prod LocalStackΛ࢖ͬͯϩʔΧϧͰDynamoDBΛΤϛϡϨʔτ͢Δ͜ͱΛ
 લఏͱ͍ͯ͠·͢ɻར༻͢Δϙʔτ͸4569Ͱ͢ɻ(ެࣜΑΓ) dev,test,prod؀ڥશͯͰIAMΛ࢖ͬͯೝূ͍ͤͯ͞·͢ɻ IAMΛ࢖͏ͱೝূ৘ใΛιʔείʔυʹهड़͢Δඞཁ͕ͳ͍ͷͰྑ͍Ͱ͢ɻ

  12. ࣮૷ྫ ࠓճ͸save()ͱall()Λ࢖͍·ͨ͠ɻ ͨͩɺRDBͰ͸ͳ͍DBʹରͯ͠
 Eloquent ORMΛར༻͢Δͷ͸
 Ͳ͏ͳͷͩΖ͏ͱࢥͬͯ͠·͍·͢ɻ

  13. LumenͱSNS

  14. AWS SNS • ௨஌ΛૹΔ͜ͱ͕Ͱ͖ΔαʔϏε
 push௨஌ • ϝʔϧૹ৴͸SESͷํ͕޲͍͍ͯΔ • SESʹ͸౦ژϦʔδϣϯ͕ͳ͘
 SNSʹ͸͋Δ

  15. खॱ 1. AWS SDKͷಋೖ(্هͰಋೖࡁΈ) 2. bootstrap/app.phpͷमਖ਼ 3. config/sns.phpΛ࡞੒ 4. envϑΝΠϧΛ࡞੒

  16. bootstrap/app.phpͷमਖ਼

  17. config/sns.phpΛ
 ࡞੒

  18. envϑΝΠϧ࡞੒ .env.local LocalStackΛ࢖ͬͯϩʔΧϧͰSNSΛΤϛϡϨʔτ͢Δ͜ͱΛલఏͱ͍ͯ͠·͢ɻ
 ϩʔΧϧͰ࡞੒ࡁΈͷτϐοΫͷARNΛSNS_TOPIC_ARNʹهࡌ͠·͢ɻ
 ར༻͢Δϙʔτ͸4575Ͱ͢ɻ(ެࣜΑΓ)

  19. envϑΝΠϧ࡞੒ .env.dev .env.test .env.prod dev,test,prod؀ڥશͯͰIAMΛ࢖ͬͯೝূ͍ͤͯ͞·͢ɻ IAMΛ࢖͏ͱೝূ৘ใΛιʔείʔυʹهड़͢Δඞཁ͕ͳ͍ͷͰྑ͍Ͱ͢ɻ (SNS_CONNECTION͸֤؀ڥͰมߋ)

  20. ࣮૷ྫ

  21. https://qiita.com/yoppie_x/items/ 9b4c6a578227d4ba5cda