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

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

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

Daijiro Wachi

July 30, 2021
Tweet

More Decks by Daijiro Wachi

Other Decks in Technology

Transcript

  1. Daijiro Wachi - @watilde
    amplify-cliͰ௥Ճͨ͠functionʹ

    ؀ڥม਺ɾγʔΫϨοτΛઃఆ͢Δػೳ͕
    ͲͷΑ͏ʹ࣮૷͞Ε͔ͨ
    Amplify Boost Up#1
    2021/07/30

    View full-size slide

  2. 7/7🎋ʹϦϦʔε͞Εͨ@aws-amplify/[email protected]ͷ৽ػೳ
    ؀ڥม਺ɾγʔΫϨοτͷ؅ཧ
    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/
    ࣮ࡍͷίϛοτ ϦϦʔεهࣄ ެࣜυΩϡϝϯτ

    View full-size slide

  3. ͓࿩͢Δ͜ͱ
    • Summary

    • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ

    • Approach

    • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔

    • ؀ڥม਺؅ཧͷٕज़తͳৄࡉ

    • Conclusion

    • ·ͱΊ

    View full-size slide

  4. ͓࿩͢Δ͜ͱ
    • Summary

    • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ

    • Approach

    • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔

    • ؀ڥม਺؅ཧͷٕज़తͳৄࡉ

    • Conclusion

    • ·ͱΊ

    View full-size slide

  5. ࢖͍ํ - ؀ڥม਺
    ৽ن௥Ճ͢Δfunctionʹ؀ڥม਺ͷઃఆΛ͢Δํ๏

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  12. ͓࿩͢Δ͜ͱ
    • Summary

    • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ

    • Approach

    • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃΛਐΊ͔ͨ

    • ؀ڥม਺؅ཧͷٕज़తͳৄࡉ

    • Conclusion

    • ·ͱΊ

    View full-size slide

  13. ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃΛਐΊ͔ͨ
    ࣗ෼ࢹ఺ͰɺͲͷΑ͏ʹҙࢥ൑அΛߦ͔ͬͨ
    1. Feature request͕GitHub issuesʹ࡞੒͞ΕΔ

    2. ࡞੒͞ΕͨissueΛݩʹٞ࿦΍👍͕ߦΘΕΔ

    3. ࣮ݱՄೳੑɺΠϯύΫτͳͲෳ਺ͷ߲໨Λݩʹ༏ઌॱҐ෇͚

    4. ઃܭɾ࣮૷ͷ࣮ࢪ

    5. ίʔυϨϏϡʔͷ࣮ࢪ
    ※ৗʹ͜ͷϓϩηε͕ద༻͞Ε͍ͯΔΘ͚Ͱ͸͋Γ·ͤΜ

    View full-size slide

  14. 1. Feature request͕GitHub issuesʹ࡞੒͞ΕΔ
    Source: https://github.com/aws-amplify/amplify-cli/issues/2227
    User storyԽΛҙࣝ͠ʮ୭͕ɺԿΛɺͳͥɺߦ͍͍ͨͷ͔ʯ͕ఏڙ͞ΕΔ͜ͱ͕ଟ͍

    View full-size slide

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

    View full-size slide

  16. 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+

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  20. ؀ڥม਺؅ཧͷٕज़తͳৄࡉ
    amplify/
    team-provider-info.json
    amplify/backend/function//
    function-parameter.json
    amplify/backend/function//
    cloudformation-template.json
    Value https://example.com
    ಺෦తͳKey serviceUrl serviceUrl serviceUrl
    ݺͼग़͠༻ͷKey SERVICE_URL SERVICE_URL
    (ར༻͢ΔࡍʹҙࣝΛ͢Δඞཁ͸ͳ͍ͱࢥ͍·͢)

    View full-size slide

  21. amplify/team-provider-info.json
    “؀ڥ(env)͝ͱ” ʹ஋͕֨ೲ͞ΕΔ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  24. ͓࿩͢Δ͜ͱ
    • Summary

    • ؀ڥม਺ɾγʔΫϨοτ؅ཧػೳͷ࢖͍ํ

    • Approach

    • ͲͷΑ͏ʹ؀ڥม਺؅ཧͷ։ൃ͕ਐΜͩͷ͔

    • ؀ڥม਺؅ཧͷٕज़తͳৄࡉ

    • Conclusion

    • ·ͱΊ

    View full-size slide

  25. ใࠂΛఏҊʹɺఏҊΛٞ࿦ʹɺٞ࿦Λ࣮ݱʹ
    ^ࣗ෼͕ࢥ͏OSS։ൃͷੈք؍
    • ҙࢥ൑அ͸upstreamͰߦΘΕ͍ͯΔ

    • ҙݟΛڞײͷ֫ಘ͕Ͱ͖ΔఏҊ΁ͱঢ՚͢Δͱٞ࿦΁ͱൃల͢Δ

    • Өڹൣғͷ࠷খԽͱઃܭͷॊೈੑ͸τϨʔυΦϑʹͳΔ͜ͱ͕͋Δ

    • OSS։ൃʹ͓͍ͯ΋ɺ

    ௨ৗͷϓϩμΫτ։ൃͷΑ͏ͳΞϓϩʔνͰ

    มԽΛى͜͢͜ͱ͕Ͱ͖Δ͜ͱ͕͋Δ

    View full-size slide