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

AWS LambdaからSlackに ○○を送る

AWS LambdaからSlackに ○○を送る

Daisuke Konishi

December 20, 2017
Tweet

More Decks by Daisuke Konishi

Other Decks in Programming

Transcript

  1. "84-BNCEB͔Β4MBDLʹ
    ˓˓ΛૹΔ
    %BJTVLF,0/*4)*

    View full-size slide

  2. !TLE@OX
    Daisuke KONISHI
    DPSPVUJOFJOD8FCؒٝآص،
    8FCϑϩϯτΤϯυ͕ϝΠϯ

    όοΫΤϯυͷ࣮૷ 1ZUIPO %#
    Λษڧத

    View full-size slide

  3. IUUQTTQFBLFSEFDLDPNELPOJTIJNJOHIPVSJ
    LVSBJLBSBBMFYBXPMFTJNV

    View full-size slide

  4. IUUQTTQFBLFSEFDLDPNELPOJTIJ[VJKJO
    ZBUVUBDTTGBMTFTIFKJUPZBUVUFNJUFHBO[JUBLPUP

    View full-size slide

  5. -BNCEBͰ4MBDLʹ

    ϝοηʔδΛૹΔ

    View full-size slide

  6. ͜Μͳײ͡
    XFCIPPL

    View full-size slide

  7. 1ZUIPOW
    w MBNCEBKTPO
    w SFRVJSFNFOUTUYU
    w MBNCEB@GVODUJPOQZ
    1ZUIPOͰεΫϦϓτΛ࡞੒
    MBNCEBVQMPBEFS͸σΟϨΫτϦ಺
    Λ[JQʹͯ͠ΞοϓϩʔυΛͯ͘͠ΕΔ

    View full-size slide

  8. def lambda_handler(event, context):
    slack_message = {
    'channel': SLACK_CHANNEL,
    ‘text’: ‘test',
    ‘icon’: ':penguin:',
    }
    res = requests.post(SLACK_POST_URL,
    data=json.dumps(slack_message))
    ྫ͑͹͜Μͳͷ

    View full-size slide

  9. εΫϦϓτॻ͍ͯΞοϓͨ͠Β

    View full-size slide

  10. FY
    ؀ڥϑΝΠϧΛؚΊͣɺΞοϓ͠ͳ͍ ༰ྔ੍ݶରࡦ

    $ lambda-uploader --no-virtualenv --no-upload

    λ Building Package

    λ Fin
    -BNCEB6QMPBEFS
    BXTDMJͷ৘ใΛݩʹɺ؀ڥ಺ͷϑΝΠϧΛ[JQͰ·ͱΊͯ

    Ξοϓϩʔυ͢Δ

    $ lambda-uploader

    View full-size slide

  11. IUUQTCMPHEBJTVLFLPOJTIJDPNQPTUMBNCEBTMBDLIUNM

    View full-size slide

  12. -BNCEBͰ4MBDLʹ

    σʔλΛૹΔ

    View full-size slide

  13. IUUQTDPSPVUJOFDPN
    ίʔϙϨʔταΠτͷϦσβΠϯΛͨ͠

    View full-size slide

  14. IUUQTDPSPVUJOFDPN
    w17΍ݕࡧϫʔυɺྲྀೖݩɺΠϕϯτͳͲ

    େମݟ͍ͨ΋ͷ͸ܾ·͍ͬͯΔ
    wͪΐ͘ݟʹߦ͘ͷ͸໘౗
    ίʔϙϨʔταΠτͷϦσβΠϯΛͨ͠
    (PPHMF"OBMZUJDTͰܰ͘ΞΫηεղੳத

    View full-size slide

  15. (PPHMF"OBMZUJDT
    4MBDLʹ௨஌͢Δͱָͦ͏

    View full-size slide

  16. ͜Μͳײ͡ʹ௨஌͕͘Δ
    ˞ςετͰݸਓϒϩάͷ৘ใΛरͬͨͱ͖ͷ΍ͭ

    View full-size slide

  17. -BNCEBΛ৮ͬͯΈͯ
    w ׳ΕΕ͹ͬ͘͞ͱ࡞ΕΔͩΖ͏͠ศརͦ͏
    w ݁ߏͳϦΫΤετ਺·Ͱ՝ۚʹͳΒͳ͍ͷͰ

    ͪͬͪΌ͍͜ͱ΍Δ͏ͪͳΒ͓ࡒ෍ʹ༏͍͠
    w $MPVE8BUDIͰఆ࣮࣌ߦ΋Ͱ͖ͯخ͍͠
    w σόοάେม ֬ೝ·Ͱ͕௕͍

    View full-size slide

  18. ࠓޙ
    w QZUIPOMBNCEBMPDBMࢼͯ͠Έ͍ͨ

    -BNCEBͷϩʔΧϧ࣮ߦ؀ڥ
    w "1*(BUFXBZ͕͍·͍ͪ෼͔ͬͯͳ͍ͷͰ৮Δ

    View full-size slide