Slide 1

Slide 1 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 Terraform v0.12.29 → v1.0.5ʹ όʔδϣϯΞοϓ͢Δ্ͰؾΛ͚ͭΔ͜ͱ ϥϯαʔζגࣜձࣾ 
 SRE/҆ୡ ྋ

Slide 2

Slide 2 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΞδΣϯμ ɾࣗݾ঺հ ɾഎܠ ɾ֤αʔϏεͱDeployαʔόʔʹ͍ͭͯ ɾCircleCI x Terraform ɾόʔδϣϯΞοϓͷྲྀΕ ɹɾv0.12.29 → v1.0.5 ɾΤϥʔରԠʹ͍ͭͯ ɾv1.0.0(GA)ͷϦϦʔε ɾv1.0.5(࠷৽)όʔδϣϯΞοϓͯ͠Έͯ ɾ·ͱΊ

Slide 3

Slide 3 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ࣗݾ঺հ

Slide 4

Slide 4 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ࣗݾ঺հ ɾ҆ୡ ྋ(adachin) ɾLancers SRE 2018/5~ ɾ@adachin0817 ɾRVIRUS0817 ɾblog.adachin.me ɾwiki.adachin.me ɾݸਓ։ൃ΋ ɾήʔϜ࣮گYouTuber

Slide 5

Slide 5 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ͪͳΈʹ partᶃ

Slide 6

Slide 6 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ͪͳΈʹ partᶃ ɾSUPER STUDIO 2014~ ɾCROਅ໺͞Μͱݩಉ྅ ɾ౰࣌͸ecforceϦϦʔεͨ͠͹͔ͬ ɹɾΦϑΟε͸Ӭాொ ɾΤϯδχΞ͕͜Ε͔Βू·Δ࣌ظ ɾٕज़ϑΥϩʔ ɾPC௚͕֮ͯͨ͑͋͠Δ ɾݱࡏ͸CM·Ͱߦͳ͍ͬͯΔͷͰײಈ ɾҎલ͔Βษڧձ࣮ࢪ͔ͨͬͨ͠ʂ

Slide 7

Slide 7 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ͪͳΈʹ partᶄ MENTAͰ͸..

Slide 8

Slide 8 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ͪͳΈʹ partᶄ ɾΠϯϑϥ/αʔόʔ ίʔνϯά ɾMENTAϥϯΩϯά ɹɾ4Ґʂ ɾྦྷܭ189ਓʂ 
 ɹɾۦ͚ग़͠ΤϯδχΞϑΥϩʔ ɹɾస৬࣮੷ଟ਺༗Γ

Slide 9

Slide 9 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷഎܠ

Slide 10

Slide 10 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷഎܠ ɾTerraformͷόʔδϣϯ͸v0.12.29ͷ··։ൃ ɹɾv0.12ܥ͸2019೥ϦϦʔε ɾࠓ೥ͷ3݄ͰάϧʔϓձࣾͷAWSҠߦ͕׬ྃͨ͠ ɹɾLancers Creative(Rails) ɹɾPROsheet(CakePHP) 
 ɹɾLancers Agent(CakePHP) 
 ɹɾMENTA(Laravel) ɾ4݄ʹv0.15.0͕ϦϦʔε͞ΕΔ 
 ɹɾ͕͢͞ʹةػײ ɾόʔδϣϯΞοϓΛܾߦʂʂ 😇

Slide 11

Slide 11 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ֤αʔϏεͱ Deployαʔόʔͷ໾ׂʹ͍ͭͯ ͦͷલʹ

Slide 12

Slide 12 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ֤αʔϏεͱDeployαʔόʔʹ͍ͭͯ ɾTerraformͷ؅ཧ(AWSͷΞΧ΢ϯτ͸αʔϏε͝ͱʹ෼ׂ) 
 ɾDeployαʔόʔ(EC2) ɹɾ֤σΟϨΫτϦ͝ͱʹϦϙδτϦΛ഑ஔ ɾԼهαʔϏε͸શϦιʔεTerraformԽ ɹɾLancers Creative ɹɾPROsheet 
 ɹɾLancers Agent 
 ɹɾMENTA ɹɾ͢΂ͯECS/FargateʹΑΔίϯςφͰӡ༻ ɾLancersຊମ͸Ұ෦TerraformԽ ɹɾࠓޙ͸import͢Δ༧ఆ

Slide 13

Slide 13 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraform

Slide 14

Slide 14 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraform ɾCI/CD͸͢΂ͯCircleCIΛར༻ ɾCircleCI x Terraform ɹɾterraform validate ɹɾterraform plan ɹɾpush࣌ʹSlack΁௨஌(Τϥʔ΋) ɾࠓޙ͸apply΋Ͱ͖ΔΑ͏ʹ ɹɾDeployαʔόʔ͸ഇࢭ͢Δ༧ఆ ɾTerraform CIʹؔͯ͠͸ϒϩάॻ͍͍ͯ·͢

Slide 15

Slide 15 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷྲྀΕ v0.12.29 → v0.15.0

Slide 16

Slide 16 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷྲྀΕ(v0.12.29 → v0.15.0) 1. ϒϥϯν࡞੒ޙɺDeployαʔόʔͰTerraform v0.13.0ʹ্͛Δ 2. terraform init -reconfigure (providerΛ࠷৽) 3. terraform 0.13upgrade 4. terraform planʹΑΓࠩ෼Λमਖ਼͢Δ 5. tfstateϑΝΠϧͷमਖ਼ 6. terraform planͰࠩ෼͕ͳ͘ͳͬͨΒv0.15.0ʹόʔδϣϯΞοϓ 7. terraform state replace-provider registry.terraform.io/-/aws 8. hashicorp/aws ʹΑΔϓϩόΠμʔมߋ 9. terraform init 10 .terraform planͰࠩ෼͕ͳ͘ͳ͍ͬͯΕ͹όʔδϣϯΞοϓ׬ྃ ͍͖ͳΓv0.12͔Β v0.15ʹ͸্͛ΒΕͳ͍ʂ ঃʑʹࠩ෼Λͳ͍ͯ͘͜͠͏ʂ ❌

Slide 17

Slide 17 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ Warning: Version constraints inside provider configuration blocks are deprecated

Slide 18

Slide 18 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ ɾWarning: Version constraints inside provider configuration blocks are deprecated ɾv0.13Ҏલ ɾproviderߏ੒͕ϒϩοΫ಺ʹͯϓϩόΠμʔόʔδϣ ϯͷ੍໿͕͋ͬͨ ɹɾprovider configuration blockͷதͰproviderͷ όʔδϣϯΛࢦఆ͠ͳ͍Α͏ʹ͢Δඞཁ͕͋Δ ɾݱࡏ͸ඇਪ঑ ɾϓϩόΠμʔόʔδϣϯΛrequired_providersʹҠߦ ͢Δ͜ͱͰղܾ

Slide 19

Slide 19 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ Error: Invalid resource instance data in state

Slide 20

Slide 20 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ ɾError: Invalid resource instance data in state ɾv0.13ʹͯഇࢭ͞Εͨύϥϝʔλʔ͕͋Δ ɹɾtfstateϑΝΠϧʹ࢒͍ͬͯΔͱΤϥʔ ɹɾର৅ύϥϝʔλΛ࡟আ͢Δ ɹɾterraform init͠௚ͤ͹ղܾ ɾඞͣtfstateϑΝΠϧΛόοΫΞοϓऔΔ͜ͱʂ ɾෆཁͳύϥϝʔλʔ͸12ͭ͋ͬͨɹˠ

Slide 21

Slide 21 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 .terraform.lock.hcl ʹ͍ͭͯ

Slide 22

Slide 22 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 .terraform.lock.hclʹ͍ͭͯ ɾhttps://www.terraform.io/upgrade-guides/0- 14.html#opting-out-of-dependency-locking ɾv0.15.0ʹόʔδϣϯΞοϓޙ ɾterraform.lock.hclϑΝΠϧͱ͍͏΋ͷ͕࡞੒͞ΕΔ ɾv014.0͔Βಋೖ ɾ.terraformαϒσΟϨΫτϦʹΩϟογϡ͢ΔϩοΫ ϑΝΠϧ ɾproviderͷόʔδϣϯࢦఆ͕͋Δ৔߹ʹه࿥͞ΕΔ ɾެ͕ࣜGitͰόʔδϣϯ؅ཧ͢΂͖ͱهࡌ͞Ε͍ͯΔ ɹɾରԠࡁΈ

Slide 23

Slide 23 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraformͷ मਖ਼ ࠷ޙʹ

Slide 24

Slide 24 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraformͷमਖ਼ ɾ࠷ޙʹCircleCIͷdocker imagesΛมߋ ɾTerraform planͰࠩ෼͕Ͱͳ͍͜ͱΛ֬ೝ͢Δ ɾ࢒ΓͷϓϩδΣΫτ΋ಉ༷ʹߦ͏ ɾ࡞ۀऴྃʂ

Slide 25

Slide 25 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.0(GA)ͷϦϦʔε ͱࢥ͍͖΍…

Slide 26

Slide 26 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.0(GA)ͷϦϦʔε ɾͦͷ2ϲ݄ޙʹv1.0.0(GA)͕ϦϦʔεʂ ɹɾ҆ఆ൛ ɾݸਓతʹ4೥લ͔ΒTerraformΛར༻͍ͯ͠Δ ɹɾ౰࣌͸v0.8.5 ɾੲ͸όά͕ଟ͔ͬͨ ɹɾσΟεΫมߋͰΠϯελϯε࠶࡞੒ͳͲ ɹɾ৮Δͷʹͳ͔ͳ͔γϏΞͩͬͨ ɾ҆ఆ൛͕ग़ͨ͜ͱͰײಈϞϊ🎉 ɾv1.0.0ʹͳͬͯมΘͬͨ͜ͱ ɹɾv0.15Λϕʔεʹ͍ͯ͠Δ ɹɾେ෯ͳมߋ͸ಛʹͳ͠ ɹɾϒϩάॻ͍͍ͯΔͷͰࢀߟʹʂˠ

Slide 27

Slide 27 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.5ʹ όʔδϣϯΞοϓͯ͠Έͨ ͔ͤͬ͘ͳͷͰ

Slide 28

Slide 28 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.5ʹόʔδϣϯΞοϓͯ͠Έͨ ɾ2020/08/23 ɾTerraform v0.15.0→v1.0.5 ɹɾaws provider v3.55.0 ɾมߋ఺ ɹɾRDSύϥϝʔλʔάϧʔϓͷValue͕େจࣈʹ ɹɾElastiCacheͷόʔδϣϯ͕6.xʹࢦఆมߋ ɹɾࠩ෼मਖ਼

Slide 29

Slide 29 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.6ʂʁ ͱࢥ͍͖΍…9/4ʹͯ

Slide 30

Slide 30 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.6 😇

Slide 31

Slide 31 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ·ͱΊ

Slide 32

Slide 32 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ·ͱΊ ɾ4ͭͷϓϩδΣΫτΛόʔδϣϯΞοϓͯ͠Έͯ ɹɾ͔ͳΓۤ௧ ɹɾtfstateϑΝΠϧมߋʹ఍߅͕ͳ͘ͳͬͨ 
 ɹɾͳΜͱ͔ͳΔ ɾτϥϒϧͳ͘ରԠͰ͖ͨ ɾTerraformͷplan΍apply͕ߴ଎Խ ɾࠓޙ͸සൟʹόʔδϣϯΞοϓ͍ͯ͘͠ 
 ɹɾ൒೥ʹҰճ(֮ޛΛ࣋ͬͯ) ɾv0.12ܥͰӡ༻͍ͯ͠Δํ͸͜ͷػձʹʂ ɹɾࠓͷ͏ͪʹόʔδϣϯΞοϓ͠ͳ͍ͱ௧͍໨ʹ͋͏ ✨

Slide 33

Slide 33 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϯδχΞϒϩάͰ΋ެ։ͯ͠·͢ https://engineer.blog.lancers.jp/2021/04/versionup- terraform/

Slide 34

Slide 34 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 SREٻΉʂʂ SRE͕଍Γ·ͤΜ😇 ࠷ۙΦϯϘʔσΟϯάͷࢿྉ࡞ͬͯΈ·ͨ͠

Slide 35

Slide 35 text

2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1