AWS LambdaからSlackに ○○を送る

AWS LambdaからSlackに ○○を送る

F703b996b502414dd880bc39789faa8f?s=128

Daisuke Konishi

December 20, 2017
Tweet

Transcript

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

  2. !TLE@OX Daisuke KONISHI DPSPVUJOFJOD8FCؒٝآص، 8FCϑϩϯτΤϯυ͕ϝΠϯ
 όοΫΤϯυͷ࣮૷ 1ZUIPO %# Λษڧத

  3. IUUQTTQFBLFSEFDLDPNELPOJTIJNJOHIPVSJ LVSBJLBSBBMFYBXPMFTJNV

  4. IUUQTTQFBLFSEFDLDPNELPOJTIJ[VJKJO ZBUVUBDTTGBMTFTIFKJUPZBUVUFNJUFHBO[JUBLPUP

  5. -BNCEBͰ4MBDLʹ
 ϝοηʔδΛૹΔ 

  6. ͜Μͳײ͡ XFCIPPL

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

  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)) ྫ͑͹͜Μͳͷ
  9. εΫϦϓτॻ͍ͯΞοϓͨ͠Β

  10. FY ؀ڥϑΝΠϧΛؚΊͣɺΞοϓ͠ͳ͍ ༰ྔ੍ݶରࡦ  $ lambda-uploader --no-virtualenv --no-upload
 λ Building

    Package
 λ Fin -BNCEB6QMPBEFS BXTDMJͷ৘ใΛݩʹɺ؀ڥ಺ͷϑΝΠϧΛ[JQͰ·ͱΊͯ
 Ξοϓϩʔυ͢Δ
 $ lambda-uploader
  11. IUUQTCMPHEBJTVLFLPOJTIJDPNQPTUMBNCEBTMBDLIUNM

  12. -BNCEBͰ4MBDLʹ
 σʔλΛૹΔ 

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

  14. IUUQTDPSPVUJOFDPN w17΍ݕࡧϫʔυɺྲྀೖݩɺΠϕϯτͳͲ
 େମݟ͍ͨ΋ͷ͸ܾ·͍ͬͯΔ wͪΐ͘ݟʹߦ͘ͷ͸໘౗ ίʔϙϨʔταΠτͷϦσβΠϯΛͨ͠ (PPHMF"OBMZUJDTͰܰ͘ΞΫηεղੳத

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

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

  17. -BNCEBΛ৮ͬͯΈͯ w ׳ΕΕ͹ͬ͘͞ͱ࡞ΕΔͩΖ͏͠ศརͦ͏ w ݁ߏͳϦΫΤετ਺·Ͱ՝ۚʹͳΒͳ͍ͷͰ
 ͪͬͪΌ͍͜ͱ΍Δ͏ͪͳΒ͓ࡒ෍ʹ༏͍͠ w $MPVE8BUDIͰఆ࣮࣌ߦ΋Ͱ͖ͯخ͍͠ w σόοάେม

    ֬ೝ·Ͱ͕௕͍
  18. ࠓޙ w QZUIPOMBNCEBMPDBMࢼͯ͠Έ͍ͨ
 -BNCEBͷϩʔΧϧ࣮ߦ؀ڥ w "1*(BUFXBZ͕͍·͍ͪ෼͔ͬͯͳ͍ͷͰ৮Δ