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

Terraform v0.12.29 → v1.0.5にバージョンアップする上で気をつけること

5059d3f370ad7e1f4d8de4be79ae1a2c?s=47 adachin0817
September 08, 2021

Terraform v0.12.29 → v1.0.5にバージョンアップする上で気をつけること

https://lancersrecruit.connpass.com/event/221994/
#Lancers_SUPERSTUDIO

【Lancers x SUPER STUDIO】Engineer Meetup #1
でのLT資料となります。

5059d3f370ad7e1f4d8de4be79ae1a2c?s=128

adachin0817

September 08, 2021
Tweet

Transcript

  1. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 Terraform v0.12.29 →

    v1.0.5ʹ όʔδϣϯΞοϓ͢Δ্ͰؾΛ͚ͭΔ͜ͱ ϥϯαʔζגࣜձࣾ 
 SRE/҆ୡ ྋ
  2. 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(࠷৽)όʔδϣϯΞοϓͯ͠Έͯ ɾ·ͱΊ
  3. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ࣗݾ঺հ

  4. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ࣗݾ঺հ  ɾ҆ୡ

    ྋ(adachin) ɾLancers SRE 2018/5~ ɾ@adachin0817 ɾRVIRUS0817 ɾblog.adachin.me ɾwiki.adachin.me ɾݸਓ։ൃ΋ ɾήʔϜ࣮گYouTuber
  5. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ͪͳΈʹ partᶃ

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

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

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

    ɾΠϯϑϥ/αʔόʔ ίʔνϯά ɾMENTAϥϯΩϯά ɹɾ4Ґʂ ɾྦྷܭ189ਓʂ 
 ɹɾۦ͚ग़͠ΤϯδχΞϑΥϩʔ ɹɾస৬࣮੷ଟ਺༗Γ
  9. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷഎܠ

  10. 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͕ϦϦʔε͞ΕΔ 
 ɹɾ͕͢͞ʹةػײ ɾόʔδϣϯΞοϓΛܾߦʂʂ 😇
  11. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ֤αʔϏεͱ Deployαʔόʔͷ໾ׂʹ͍ͭͯ ͦͷલʹ

  12. 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͢Δ༧ఆ
  13. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraform

  14. 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ʹؔͯ͠͸ϒϩάॻ͍͍ͯ·͢
  15. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 όʔδϣϯΞοϓͷྲྀΕ v0.12.29 →

    v0.15.0
  16. 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ʹ͸্͛ΒΕͳ͍ʂ ঃʑʹࠩ෼Λͳ͍ͯ͘͜͠͏ʂ ❌
  17. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ Warning: Version

    constraints inside provider configuration blocks are deprecated
  18. 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ʹҠߦ ͢Δ͜ͱͰղܾ
  19. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ΤϥʔରԠʹ͍ͭͯ Error: Invalid

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

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

  22. 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Ͱόʔδϣϯ؅ཧ͢΂͖ͱهࡌ͞Ε͍ͯΔ ɹɾରԠࡁΈ
  23. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 CircleCI x Terraformͷ

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

     ɾ࠷ޙʹCircleCIͷdocker imagesΛมߋ ɾTerraform planͰࠩ෼͕Ͱͳ͍͜ͱΛ֬ೝ͢Δ ɾ࢒ΓͷϓϩδΣΫτ΋ಉ༷ʹߦ͏ ɾ࡞ۀऴྃʂ
  25. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.0(GA)ͷϦϦʔε ͱࢥ͍͖΍…

  26. 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Λϕʔεʹ͍ͯ͠Δ ɹɾେ෯ͳมߋ͸ಛʹͳ͠ ɹɾϒϩάॻ͍͍ͯΔͷͰࢀߟʹʂˠ
  27. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.5ʹ όʔδϣϯΞοϓͯ͠Έͨ ͔ͤͬ͘ͳͷͰ

  28. 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ʹࢦఆมߋ ɹɾࠩ෼मਖ਼
  29. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 v1.0.6ʂʁ ͱࢥ͍͖΍…9/4ʹͯ

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

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

  32. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 ·ͱΊ  ɾ4ͭͷϓϩδΣΫτΛόʔδϣϯΞοϓͯ͠Έͯ

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

    terraform/
  34. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1 SREٻΉʂʂ  SRE͕଍Γ·ͤΜ😇

    ࠷ۙΦϯϘʔσΟϯάͷࢿྉ࡞ͬͯΈ·ͨ͠
  35. 2021/09/8ʲLancers x SUPER STUDIOʳ Engineer Meetup #1