Slide 1

Slide 1 text

ελʔτΞοϓʹೖͬ ͯ·ͣ΍ͬͨΠϯϑϥ TIPS 2018/05/30 ελʔτΞοϓ × Πϯϑϥ ʙര଎։ൃΛߦ͏4ࣾͷ։ൃΛࢧ͑ΔΠϯϑϥઓུʙ @kotamat

Slide 2

Slide 2 text

ࣗݾ঺հ • SCOUTER CTO • @kotamat • twitter͸@kotamats •

Slide 3

Slide 3 text

೔ຊॳ঺հ໔ڐͳ͠Ͱਓࡐ঺հ͕Ͱ͖Δ
 ෭ۀܕιʔγϟϧϔουϋϯςΟϯά
 ݱࡏ ໊͕ొ࿥͠਎ۙͳస৬ر๬ऀΛ
 ܝࡌاۀʹ঺հ͢Δ͜ͱͰใु͕ൃੜ ਓࡐ঺հձࣾ ϓϩ ޲͚Ϋϥ΢υαʔϏε
 ໿ ࣾͷٻਓ%#Λఏڙ
 ঺հྉΛड͚औΕΔ ۀքॳͷ4BB4αʔϏε ̎ͭͷ)35FDIαʔϏεΛల։

Slide 4

Slide 4 text

4$065&3ͱ͸ ແྉͰ
 ܝࡌٻਓ ϓϩͷ ΤʔδΣϯτ
 ࣾ ਓ௒ͷΤʔδΣϯτωοτϫʔΫΛ׆༻ͨ͠ਓࡐ঺հ ͭͷ૭ޱͰ͝঺հऀͷ฼ूஂΛ࠷େԽ͢Δ͜ͱ͕Ͱ͖·͢ ݸਓͷ
 εΧ΢λʔ
 ਓ ٻਓΛ৐ͤΔ͚ͩʂ

Slide 5

Slide 5 text

঺հձࣾͷ਺ʹ൐ͬͯ૿͑Δ؅ཧίετ ࣮ࡍʹ঺հ͕དྷΔͷ͸Ұ෦ͷձࣾͷΈ ໿ࣾ ਓ͔ΒҰׅ঺հ ෭ۀΤʔδΣϯτϓϩΤʔδΣϯτ ਓࡐ঺հͷޮՌΛ࠷େԽӡ༻ίετΛ࠷খԽ 4$065&3ͱ͸

Slide 6

Slide 6 text

೥Ͱٻਓاۀ͸ ࣾ ٻਓʹ·Ͱ੒௕த ಋೖࣄྫ

Slide 7

Slide 7 text

લ৬·Ͱ͸ʝ • ιγϟήձࣾͰαʔόʔαΠυΤϯδχΞ • جຊతʹӡ༻ϑΣʔζ͕ओ • ߴෛՙͳαʔϏεͷνϡʔχϯά͕ಘҙ • ৽نࣄۀܥͰ͸ɺΠϯϑϥͷߏங͔Β৭ʑ΍ͬͯͨ • ϒϩοΫνΣʔϯΫϥελͷߏ੒ɺελʔτΞοϓ ͷAWSߏ੒౳ͳͲ

Slide 8

Slide 8 text

ೖࣾ࣌ͷSCOUTER • Laravel, Vue.jsΛઌਐతʹऔΓೖΕ͍ͯΔʮٕ ज़తʹΠέͯΔʯձࣾ • ։ൃϑΣʔζ͕͋Δఔ౓མͪண͍͖ͯͯɺӡ ༻ϑΣʔζʹֻ͔͍ࠩͬͯͨ͠ • →ӡ༻ϑΣʔζʹ͓͚Δ։ൃମ੍ͷߏங͕ෆ ଍͍ͯͨ͠ɻ

Slide 9

Slide 9 text

Slide 10

Slide 10 text

։ൃϑΣʔζ

Slide 11

Slide 11 text

։ൃϑΣʔζ ӡ༻ɾվળ ϑΣʔζ

Slide 12

Slide 12 text

։ൃϑΣʔζ ӡ༻ɾվળ ϑΣʔζ ͜͜Ͱೖࣾ

Slide 13

Slide 13 text

։ൃϑΣʔζ ӡ༻ɾվળ ϑΣʔζ ͜͜Ͱೖࣾ ։ൃϑΣʔζ →ӡ༻ϑΣʔζͷ ΠϯϑϥTips ࿩͠·͢

Slide 14

Slide 14 text

࿩͢͜ͱ • εςʔδϯά • IaC • ͦͷଞ΍ͬͨ͜ͱ • ·ͱΊ

Slide 15

Slide 15 text

εςʔδϯά

Slide 16

Slide 16 text

εςʔδϯάͱ͸ • ຊ൪൓өલʹ࠷ऴ֬ೝ͢ΔͨΊͷຊ൪ͱྨࣅ ͨ͠ςετ؀ڥ εςʔδϯά ຊ൪ ≒ Ϣʔβ ࣾһ

Slide 17

Slide 17 text

εςʔδϯάͱ͸ • ຊ൪൓өલʹ࠷ऴ֬ೝ͢ΔͨΊͷຊ൪ͱྨࣅ ͨ͠ςετ؀ڥ εςʔδϯά ຊ൪ ≒ Ϣʔβ ࣾһ

Slide 18

Slide 18 text

εςʔδϯάͱ͸ • ຊ൪൓өલʹ࠷ऴ֬ೝ͢ΔͨΊͷຊ൪ͱྨࣅ ͨ͠ςετ؀ڥ εςʔδϯά ຊ൪ ≒ Ϣʔβ ࣾһ

Slide 19

Slide 19 text

Before

Slide 20

Slide 20 text

Before • masterϒϥϯνʹϚʔδ͞ΕͨΒଈຊ൪ʹ൓ө • ҰԠϑϩϯτ͚ͩ͸Heroku Review App্ཱ͕͕͍ͪͬͯͨ ͕ɺॏ͗ͯ͢࢖͑ͳ͍ʝ • ෆ۩߹ใࠂ͕͋ͬͨͱͯ͠΋ɺ࠶ݱ·Ͱʹ͕͔͔࣌ؒΔ or ࠶ݱ Ͱ͖ͳ͍ • ࣾһʹϦϦʔεલʹ֬ೝͯ͠΋Β͏ͱ͖͸ɺࣗ෼ͷ1$͔Β 0.0.0.0ͰϏϧυͯ͠ϩʔΧϧωοτϫʔΫͰݟͯ΋Β͏ɻ

Slide 21

Slide 21 text

σϓϩΠϑϩʔ

Slide 22

Slide 22 text

σϓϩΠϑϩʔ

Slide 23

Slide 23 text

push σϓϩΠϑϩʔ

Slide 24

Slide 24 text

push σϓϩΠϑϩʔ

Slide 25

Slide 25 text

push CodeDeploy Λىಈ σϓϩΠϑϩʔ

Slide 26

Slide 26 text

push CodeDeploy Λىಈ S3ʹzip ͰݻΊΔ σϓϩΠϑϩʔ

Slide 27

Slide 27 text

push CodeDeploy Λىಈ S3ʹzip ͰݻΊΔ σϓϩΠϑϩʔ

Slide 28

Slide 28 text

push CodeDeploy Λىಈ S3ʹzip ͰݻΊΔ zipΛEC2 ʹల։ σϓϩΠϑϩʔ

Slide 29

Slide 29 text

push CodeDeploy Λىಈ S3ʹzip ͰݻΊΔ zipΛEC2 ʹల։ σϓϩΠϑϩʔ

Slide 30

Slide 30 text

After

Slide 31

Slide 31 text

ߏ੒ਤ εςʔδϯά ຊ൪ σΠϦʔͰsync

Slide 32

Slide 32 text

pushޙ SlackίϚϯυ࣮ߦ σϓϩΠϑϩʔ(εςʔδϯά) hubot͕ݕग़ capistranoىಈ σϓϩΠ

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

ର৅ϒϥϯνΛࢦఆ

Slide 35

Slide 35 text

ී௨ʁ

Slide 36

Slide 36 text

匠技

Slide 37

Slide 37 text

ঊٕ() • ຊ൪؀ڥ͔ΒεςʔδϯάDB΁ͷγϯΫ࣌͸ɺ ػີ৘ใΛϚεΩϯάͯ͠ಉظ • ϩάΠϯύεϫʔυ͸։ൃ͕ϩάΠϯՄೳͳܗ ʹ੔ܗ • εςʔδϯάσϓϩΠ࣌ or ਂ໷ʹຊ൪؀ڥ͔ ΒDBγϯΫͰ͖ΔΑ͏ʹ

Slide 38

Slide 38 text

DBϚεΩϯά • ݸਓ৘ใΛӅͨ͢ΊͷγϯΫલॲཧ • ςʔϒϧ໊ɺΧϥϜ໊ɺՃ޻ํ๏Λࢦఆͯ͠ϚεΩϯάΛߦ͏ • Ճ޻ํ๏ • ࢦఆͨ͠஋ʹॻ͖׵͑ • จࣈྻ຤ඌʹsuffixΛ௥Ճ • ਺஋ΛϥϯμϜͳ΋ͷʹॻ͖׵͑ • 3จࣈ໨Ҏ߱Λଞͷจࣈʹॻ͖׵͑ • yamlͰઃఆ

Slide 39

Slide 39 text

yamlྫ - table_name: users columns: - name: email suffix: x - name: numeric_data calc: true - name: last_name len: 1 - name: tel - name: default default: 18793jjdiaerheihu3qoh4u3qh4u3i2qhu43qh - name: uri conditions: - condition: "`status`='active'" value: some/path/of/uri - condition: "`status`='pending'" value: other/path/of/uri - table_name: companies columns:

Slide 40

Slide 40 text

ϩάΠϯύεϫʔυͷ੔ܗ • Ϣʔβ͔Βͷෆ۩߹ใࠂͷதͰɺ࠶ݱͰ͖ͳ ͍Τϥʔ͕ൃੜ͢Δ͜ͱ͕͋Δɻ • ຊ൪σʔλͱಉ͡σʔλͰϩάΠϯͰ͖Ε͹ ࠶ݱ͕Մೳͳࣄ͕ଟ͍ • ύεϫʔυΛࣾһ͕ΞΫηεՄೳͳܗʹ੔ܗ ͓ͯ͘͠

Slide 41

Slide 41 text

DBͷγϯΫλΠϛϯά • σϓϩΠ࣌ʹຊ൪DBΛ͍ͭͰ΋γϯΫͰ͖ΔΑ ͏ʹ͍ͯ͠Δ • migration౳ͰͷΤϥʔ͕ൃੜͨ͠ͱͯ͠΋ɺ ͍ͭͰ΋ݩͷঢ়ଶʹ໭ͤΔ • ෆ۩߹ௐࠪ౳͙͢ʹ֬ೝ͍ͨ͠ͱ͖ͷͨΊʹɺ σΠϦʔͰຊ൪DB͔ΒͷγϯΫΛߦ͍ͬͯΔ

Slide 42

Slide 42 text

DBγϯΫ

Slide 43

Slide 43 text

DBγϯΫ γϯΫ࣌ͷίϚϯυʹ Φϓγϣϯࢦఆ͢Δ͚ͩ

Slide 44

Slide 44 text

なんという 事でしょう

Slide 45

Slide 45 text

ͳΜͱ͍͏ࣄͰ͠ΐ͏(·ͱΊ) • ຊ൪؀ڥͷྨࣅ؀ڥʹྨࣅ͍ͯ͠Δ͕ɺ৘ใ తʹ҆શͳ؀ڥΛ੔උͰ͖ͨ • ڍಈ֬ೝ౳ͷඞཁ࠷௿ݶ΍Γ͍ͨ͜ͱͷΈ ϑΥʔΧεͰ͖ΔΑ͏ʹͳͬͨ • Ϣʔεέʔεʹ߹Θͤͯɺ೚ҙͷλΠϛϯάͰ ٻΊΔ؀ڥΛߏஙͰ͖ΔΑ͏ʹͳͬͨɻ

Slide 46

Slide 46 text

࿩͢͜ͱ • εςʔδϯά • IaC • ͦͷଞ΍ͬͨ͜ͱ • ·ͱΊ

Slide 47

Slide 47 text

IaC

Slide 48

Slide 48 text

IaCͱ͸ • Infrastructure as Codeͷུ • ΠϯϑϥߏஙΛίʔυͰهड़͠Α͏ͥ

Slide 49

Slide 49 text

Before

Slide 50

Slide 50 text

Before • AWSͷWebίϯιʔϧ্Ͱϙνϙν؀ڥઃఆ • αʔϏε͕૿͑ͯ͘Δͨͼʹಉ͜͡ͱΛ͍ͯͨ͠ɻ • ‥͕ɺґଘαʔϏε͕ଟ͘ɺߏஙʹ͕͔͔࣌ؒΔ • ͞Βʹɺ಺෦ߏ଄͕ϒϥοΫϘοΫεԽ͢Δ͜ͱͰҾ ͖ܧ͕͗େมɻ • ݁Ռ࠷ॳʹߏஙͨ͠ਓ͕୯Ұো֐఺ʹ

Slide 51

Slide 51 text

ߏ੒ਤ

Slide 52

Slide 52 text

ߏ੒ਤ ×αʔϏε෼

Slide 53

Slide 53 text

After

Slide 54

Slide 54 text

After • AWSͷߏ੒ˠTerraformʹҠߦ • EC2಺ͷϛυϧ΢ΣΞͷઃఆˠAnsibleʹҠߦ

Slide 55

Slide 55 text

匠技

Slide 56

Slide 56 text

ঊٕ? • ߏ੒ͷίʔυ༻ͷϦϙδτϦΛ༻ҙ • αʔϏεؒͰڞ༗͍ͯ͠ΔϦιʔεͱɺαʔ Ϗε͝ͱͷϦιʔε͸σΟϨΫτϦ෼͚Δ • Terraformͷ؀ڥม਺͸gitignore͢Δ • Terraformͷ࣮ߦεΫϦϓτ΋gitʹ৐͚ͬΔ

Slide 57

Slide 57 text

ߏ੒ͷίʔυ༻ͷϦϙδτϦΛ ༻ҙ • Github্ʹίʔυ؅ཧ༻ͷϦϙδτϦΛ༻ҙ • PRϕʔεͰίʔυΛ؅ཧ͢Δ͜ͱͰɺͲ͏͍ ͏ҙਤͰͦͷมߋΛߦ͔ͬͨΛՄࢹԽ • ଐਓੑͷഉআ

Slide 58

Slide 58 text

σΟϨΫτϦߏ੒ ᵓᴷᴷ global ᵓᴷᴷ service1 ᴹ ᵓᴷᴷ ansible ᴹ ᴹ ᵓᴷᴷ app ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ec2-boot ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ecs ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ nginx ᴹ ᴹ ᴹ ᵓᴷᴷ defaults ᴹ ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᴹ ᵋᴷᴷ php ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᵋᴷᴷ policies ᵓᴷᴷ service2 ڞ௨෦෼ͷهड़

Slide 59

Slide 59 text

σΟϨΫτϦߏ੒ ᵓᴷᴷ global ᵓᴷᴷ service1 ᴹ ᵓᴷᴷ ansible ᴹ ᴹ ᵓᴷᴷ app ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ec2-boot ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ecs ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ nginx ᴹ ᴹ ᴹ ᵓᴷᴷ defaults ᴹ ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᴹ ᵋᴷᴷ php ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᵋᴷᴷ policies ᵓᴷᴷ service2 αʔϏεͷUGϑΝΠ ϧͷ؅ཧ

Slide 60

Slide 60 text

σΟϨΫτϦߏ੒ ᵓᴷᴷ global ᵓᴷᴷ service1 ᴹ ᵓᴷᴷ ansible ᴹ ᴹ ᵓᴷᴷ app ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ec2-boot ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ecs ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ nginx ᴹ ᴹ ᴹ ᵓᴷᴷ defaults ᴹ ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᴹ ᵋᴷᴷ php ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᵋᴷᴷ policies ᵓᴷᴷ service2 "OTJCMFͷ؅ཧ

Slide 61

Slide 61 text

σΟϨΫτϦߏ੒ ᵓᴷᴷ global ᵓᴷᴷ service1 ᴹ ᵓᴷᴷ ansible ᴹ ᴹ ᵓᴷᴷ app ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ec2-boot ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ ecs ᴹ ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᴹ ᵓᴷᴷ nginx ᴹ ᴹ ᴹ ᵓᴷᴷ defaults ᴹ ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᴹ ᵋᴷᴷ php ᴹ ᴹ ᵓᴷᴷ handlers ᴹ ᴹ ᵋᴷᴷ tasks ᴹ ᵋᴷᴷ policies ᵓᴷᴷ service2 ͭ໨Ҏ߱ͷαʔϏε

Slide 62

Slide 62 text

؀ڥม਺ͷgitignore • ϦϙδτϦ؅ཧͷ౎߹্ɺ୭Ͱ΋clone͢Ε͹ ίʔυΛऔಘͰ͖ΔΑ͏ʹͳ͍ͬͯΔɻ • ࣮ߦݖݶ͸AWSͷkeyΛอ༗͍ͯ͠Δඞཁ͕͋ Δ • AWSͷkey౳ͷσʔλ͸git؅ཧͤͣɺඞཁͳλ ΠϛϯάͰݸʑਓ͕ઃఆ͢Δඞཁ͕͋Δɻ

Slide 63

Slide 63 text

Terraformͷ࣮ߦεΫϦϓτ΋git ʹ৐͚ͬΔ • SCOUTERࣾ͸PhpStormΛશһ࢖༻͍ͯ͠Δ • PhpStorm༻ͷ࣮ߦεΫϦϓτ΋อଘ͓ͯ͘͠ ͜ͱͰɺ୭Ͱ΋࣮ߦ͕Մೳͳܗʹ͍ͯ͠Δɻ • ΋ͪΖΜAWSͷkey౳͸ඞཁͳਓʹͷΈ෇༩͠ ͍ͯΔͷͰɺͩΕͰ΋࣮ߦͰ͖ΔΘ͚Ͱ͸ͳ͍

Slide 64

Slide 64 text

gitignore͸Jetbrains੡඼͕ੜ੒͢Δ΋ͷΛ࢖༻͢Δ

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

なんという 事でしょう

Slide 67

Slide 67 text

ͳΜͱ͍͏ࣄͰ͠ΐ͏(·ͱΊ) • IaCʹ͢Δ͜ͱʹΑͬͯɺଐਓੑΛഉআͰ͖Δ • IaC͢Δ৔߹΋΋ͪΖΜ࣮ߦՄೳͳਓΛ੍ݶͰ͖ ΔΑ͏ʹɺgitignore͸ઃఆ͠Α͏ • ΤσΟλͷ࣮ߦઃఆΛ͢Δ͜ͱͰ • ͍·͙͢IaC͠Ζʂ

Slide 68

Slide 68 text

࿩͢͜ͱ • εςʔδϯά • IaC • ͦͷଞ΍ͬͨ͜ͱ • ·ͱΊ

Slide 69

Slide 69 text

ͦͷଞ΍ͬͨ͜ͱ

Slide 70

Slide 70 text

ͦͷଞ΍ͬͨ͜ͱ • ୺຤؅ཧ • ΞΫηεݖݶͷ੍ݶɺ؅ཧ • VPNͷ੔උ • Gsuiteͷ׆༻

Slide 71

Slide 71 text

·ͱΊ

Slide 72

Slide 72 text

·ͱΊ • ։ൃϑΣʔζ͔Βӡ༻ϑΣʔζʹมΘΔλΠ ϛϯάͰ৭ʑͱ੔උͨ͠ɻ • ։ൃޮ཰Λ͞Βʹര଎ʹ͢Δɺ߈ΊͷΠϯϑ ϥͳͷͰɺ΍ͬͯͳ͍ͱ͜Ζ͸΍ͬͨ΄͏͕ ͍͍ɻ

Slide 73

Slide 73 text

࠷ޙʹ SCOUTERࣾͰ͸ɺҰॹʹؤுͬͯ͘ΕΔ 匠 Λืू͓ͯ͠Γ·͢ɻ http://bit.ly/scouter-takumi Πϯϑϥ / Nuxt / Vue / Laravel