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

amplify-cliで追加したfunctionに
環境変数・シークレットを設定する機能が どのように実現されたか / amplify-env-vars

amplify-cliで追加したfunctionに
環境変数・シークレットを設定する機能が どのように実現されたか / amplify-env-vars

1d5ca7d8f17f15de4272e1ec7ef7abac?s=128

Daijiro Wachi

July 30, 2021
Tweet

Transcript

  1. Daijiro Wachi - @watilde amplify-cliͰ௥Ճͨ͠functionʹ
 ؀ڥม਺ɾγʔΫϨοτΛઃఆ͢Δػೳ͕ ͲͷΑ͏ʹ࣮૷͞Ε͔ͨ Amplify Boost Up#1

    2021/07/30
  2. None
  3. 7/7🎋ʹϦϦʔε͞Εͨ@aws-amplify/cli@5.1.0ͷ৽ػೳ ؀ڥม਺ɾγʔΫϨοτͷ؅ཧ Commit hash: fac354e Source: https://aws.amazon.com/jp/blogs/mobile/con fi gure-environment-variables-and-secrets-for-your-lambda-functions-with-amplify-cli/ ࣮ࡍͷίϛοτ

    ϦϦʔεهࣄ ެࣜυΩϡϝϯτ
  4. ͓࿩͢Δ͜ͱ • Summary • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ • Approach • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔ •

    ؀ڥม਺؅ཧͷٕज़తͳৄࡉ • Conclusion • ·ͱΊ
  5. ͓࿩͢Δ͜ͱ • Summary • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ • Approach • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔ •

    ؀ڥม਺؅ཧͷٕज़తͳৄࡉ • Conclusion • ·ͱΊ
  6. ࢖͍ํ - ؀ڥม਺ ৽ن௥Ճ͢Δfunctionʹ؀ڥม਺ͷઃఆΛ͢Δํ๏

  7. ࢖͍ํ - ؀ڥม਺ Advanced settingsΑΓɺKeyͱValueΛೖྗ

  8. ࢖͍ํ - ؀ڥม਺ process.env ܦ༝Ͱ஋ͷݺͼग़͠

  9. ࢖͍ํ - Secret ৽ن௥Ճ͢ΔfunctionʹγʔΫϨοτͷઃఆΛ͢Δํ๏

  10. ࢖͍ํ - Secret Advanced settingsΑΓɺKeyͱValueΛೖྗ

  11. ࢖͍ํ - Secret SSM(AWS Secrets Manager) ܦ༝Ͱ஋Λݺͼग़͠

  12. ࢖͍ํ - Secret SSM(AWS Secrets Manager) ܦ༝Ͱ஋Λݺͼग़͠

  13. ͓࿩͢Δ͜ͱ • Summary • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ • Approach • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃΛਐΊ͔ͨ •

    ؀ڥม਺؅ཧͷٕज़తͳৄࡉ • Conclusion • ·ͱΊ
  14. ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃΛਐΊ͔ͨ ࣗ෼ࢹ఺ͰɺͲͷΑ͏ʹҙࢥ൑அΛߦ͔ͬͨ 1. Feature request͕GitHub issuesʹ࡞੒͞ΕΔ 2. ࡞੒͞ΕͨissueΛݩʹٞ࿦΍👍͕ߦΘΕΔ 3. ࣮ݱՄೳੑɺΠϯύΫτͳͲෳ਺ͷ߲໨Λݩʹ༏ઌॱҐ෇͚

    4. ઃܭɾ࣮૷ͷ࣮ࢪ 5. ίʔυϨϏϡʔͷ࣮ࢪ ※ৗʹ͜ͷϓϩηε͕ద༻͞Ε͍ͯΔΘ͚Ͱ͸͋Γ·ͤΜ
  15. 1. Feature request͕GitHub issuesʹ࡞੒͞ΕΔ Source: https://github.com/aws-amplify/amplify-cli/issues/2227 User storyԽΛҙࣝ͠ʮ୭͕ɺԿΛɺͳͥɺߦ͍͍ͨͷ͔ʯ͕ఏڙ͞ΕΔ͜ͱ͕ଟ͍

  16. 2. ࡞੒͞ΕͨissueΛݩʹٞ࿦΍👍͕ߦΘΕΔ ىථ಺༰͕ڞײΛੜΉͱɺٞ࿦΁ͱൃల͞Εࢧ࣋Λड͚Δ Source: https://github.com/aws-amplify/amplify-cli/issues/2227

  17. 3. ࣮ݱՄೳੑɺΠϯύΫτͳͲෳ਺ͷ߲໨Λݩʹ༏ઌॱҐ෇͚ ఆྔతͳधཁΛݟΔͷʹ👍ͷ਺ͰιʔτΛͯ͠ΈΔ Source: https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+updated%3A%3E%3D2021-06-01+is%3Aclosed+

  18. 4. ઃܭɾ࣮૷ͷ࣮ࢪ ٞ࿦ΛಡΈࠐΈɺ࣮ࡍʹΰʔϧΠϝʔδΛܗʹͯ͠ৄࡉͳٞ࿦΁ͱൃలͤ͞Δ Source: https://github.com/aws-amplify/amplify-cli/pull/7166

  19. 5. ίʔυϨϏϡʔͷ࣮ࢪ ඼࣭ΛߴΊΔͨΊͷٞ࿦ΛPR্Ͱ࣮ࢪ Source: https://github.com/aws-amplify/amplify-cli/pull/7166

  20. ߹ҙ͕ܗ੒͞ΕϚʔδʹࢸΔ🎉 Source: https://github.com/aws-amplify/amplify-cli/commit/429c543d1d3f52da60b4c03fa48b67aedb1a661c

  21. ؀ڥม਺؅ཧͷٕज़తͳৄࡉ amplify/ team-provider-info.json amplify/backend/function/<name>/ function-parameter.json amplify/backend/function/<name>/ cloudformation-template.json Value https://example.com ಺෦తͳKey

    serviceUrl serviceUrl serviceUrl ݺͼग़͠༻ͷKey SERVICE_URL SERVICE_URL (ར༻͢ΔࡍʹҙࣝΛ͢Δඞཁ͸ͳ͍ͱࢥ͍·͢)
  22. amplify/team-provider-info.json “؀ڥ(env)͝ͱ” ʹ஋͕֨ೲ͞ΕΔ

  23. amplify/backend/function/<name>/function-parameter.json “Ϣʔβʔ͕௥Ճͨ͠” ؀ڥม਺ͷ಺෦తͳKeyͱݺͼग़͠༻ͷKeyΛfunction͝ͱʹϦετԽ

  24. amplify/backend/function/<name>/cloudformation-template.json team-provider-info.jsonʹอଘ͞Ε͍ͯΔ஋ͱݺͼग़͠༻ͷKeyͷඥ෇͚

  25. ͓࿩͢Δ͜ͱ • Summary • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ • Approach • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔ •

    ؀ڥม਺؅ཧͷٕज़తͳৄࡉ • Conclusion • ·ͱΊ
  26. ใࠂΛఏҊʹɺఏҊΛٞ࿦ʹɺٞ࿦Λ࣮ݱʹ ^ࣗ෼͕ࢥ͏OSS։ൃͷੈք؍ • ҙࢥ൑அ͸upstreamͰߦΘΕ͍ͯΔ • ҙݟΛڞײͷ֫ಘ͕Ͱ͖ΔఏҊ΁ͱঢ՚͢Δͱٞ࿦΁ͱൃల͢Δ • Өڹൣғͷ࠷খԽͱઃܭͷॊೈੑ͸τϨʔυΦϑʹͳΔ͜ͱ͕͋Δ • OSS։ൃʹ͓͍ͯ΋ɺ


    ௨ৗͷϓϩμΫτ։ൃͷΑ͏ͳΞϓϩʔνͰ
 มԽΛى͜͢͜ͱ͕Ͱ͖Δ͜ͱ͕͋Δ