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

AWS・Hubot・Slackで ChatOpsする話[実装編]

AWS・Hubot・Slackで ChatOpsする話[実装編]

AWSとHubotを用いてSlackと連携したChatOpsを行った際の実装をお話します。

6a36124a1d873c9d20b78192fce578c6?s=128

Kazuhisa Togo

November 08, 2016
Tweet

Transcript

  1. AWSɾHubotɾSlackͰ ChatOps͢Δ࿩ ࣮ ૷ ฤ Kazuhisa Togo

  2. ΞϓϦέʔγϣϯߏ੒

  3. HubotͰSlackʹ઀ଓɺ࿈ܞ

  4. Node.js ͰՔಇ

  5. DockerͰ ΞϓϦέʔγϣϯΛԾ૝Խ

  6. EC2 Πϯϑϥ͸׬શAWS

  7. Πϯϑϥ

  8. EC2 ECS ECR

  9. EC2 ECS ECR ฼؋Ϛγϯ DockerίϯςφΛ૸ΒͤΔ౔୆

  10. EC2 ECS ECR DockerίϯςφͷϚωδϝϯτ ࢮ׆؂ࢹͳͲ

  11. EC2 ECS ECR DockerΠϝʔδͷϓϥΠϕʔτஷଂݿ

  12. EC2 ECS ECR 3ͭ߹ΘͤͯDockerίϯςφ؅ཧ

  13. σϓϩΠ

  14. CIπʔϧ

  15. CodeDeployͱ૊Έ߹Θͤͯ Continuous Deployment CodeDeploy

  16. ϦιʔεɺΞϓϦέʔγϣϯͷ σϓϩΠ

  17. CodeDeploy S3 EC2 ͓͓·͔ͳྲྀΕ

  18. CodeD S3 ϦϙδτϦʹ git push

  19. CodeD S3 GitHub Hook

  20. CodeD S3 ϒϥϯνͷσʔλΛऔಘ Ϗϧυˍςετ

  21. CodeDeploy S3 E σϓϩΠ༻ͷϑΝΠϧҰࣜΛΞʔΧΠϒ S3ʹసૹ

  22. CodeDeploy S3 EC2 ४උ͕Ͱ͖ͨΒCodeDeployݺͼग़͠

  23. CodeDeploy S3 EC2 S3͔ΒΞʔΧΠϒΛμ΢ϯϩʔυ ల։ɾΠϯετʔϧ

  24. CodeDeploy S3 EC2 Πϯετʔϧॲཧ ׬ྃޙͷޙย෇͚

  25. CodeDeploy S3 EC2 σϓϩΠΛશࣗಈԽ

  26. CodeDeploy S3 EC2 ChatOpsΛ࢖ͬͨϓϩηε EC2

  27. CodeDeploy S3 EC2 Bot͔ΒσϓϩΠࢦࣔ EC2

  28. CodeDeploy S3 EC2 εςʔδϯά؀ڥʹσϓϩΠͨ͠಺༰Λ ϓϩμΫγϣϯ؀ڥʹ΋σϓϩΠ EC2

  29. ίϯςφͷ σϓϩΠ

  30. ECR ͓͓·͔ͳྲྀΕ ECS

  31. ECR CIͷϑοΫ·Ͱ͸ڞ௨ pushΛϑοΫͯࣗ͠ಈͰ։࢝ ECS

  32. ECR CircleCIͰ docker build ECS

  33. ECR ECRʹ docker push ECS

  34. ECR ECS͔Βࢀর λά࣍ୈͰ͸खଓ͖ແ͠Ͱߋ৽ ECS

  35. ECR λεΫΛ্ཱͪ͛௚͢ͱ ৽͍͠Πϝʔδ͕ࣗಈద༻ ECS

  36. ECR ͜Ε΋׬શࣗಈԽ͕Մೳ ECS

  37. AWS-SDK

  38. खް͍SDK Node.js SDK

  39. όονىಈ
 ੲͳ͕Βͷ git pull σϓϩΠetc. Node.js SDK

  40. ΠϯελϯεͷIPΛऔಘͨ͠Γ͢Δͷʹ SDKେ׆༂ Node.js SDK

  41. ΞΫηε੍ޚ

  42. ϝοηʔδͷ౤ߘϢʔβʔ͸
 SlackଆͰ ݪଇ ೝূࡁΈ

  43. ௨ৗ HubotଆͰ͸IDͷνΣοΫ͚ͩͰOK

  44. APIΛۦ࢖ͯ͠ as_user ͱ͔͞ΕͪΌͬͨ৔߹͸ྫ֎ ͦͷ৔߹͸ݖݶΛݟ௚͠·͠ΐ͏

  45. τʔΫϯͷηΩϡϦςΟʔ

  46. S3 EC2 ιʔείʔυʹೝূ৘ใΛॻ͖ࠐΉͱ ͢΂ͯͷܦ࿏Ͱ伴Λ๫࿐ͯ͠͠·͏

  47. Task Definition Ͱ؀ڥม਺ͱͯ͠ఆٛ ECS

  48. ࿙Ӯ͠͏ΔՕॴΛେ͖͘࡟ݮ ECS

  49. ΫϩεΞΧ΢ϯτΞΫηε

  50. AWSΞΧ΢ϯτΛ෼཭͍ͯ͠Δ৔߹ ௚઀ΞΫηεͰ͖ͳ͍

  51. ΫϩεΞΧ΢ϯτΞΫηε

  52. ϩʔϧΛ࡞੒

  53. STSΛ࢖ͬͯҰ࣌τʔΫϯΛऔಘ

  54. τʔΫϯΛ࢖ͬͯΞΫηε

  55. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠