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

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

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資料となります。

adachin0817

September 08, 2021
Tweet

More Decks by adachin0817

Other Decks in Programming

Transcript

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


    Terraform v0.12.29 → v1.0.5ʹ


    όʔδϣϯΞοϓ͢Δ্ͰؾΛ͚ͭΔ͜ͱ
    ϥϯαʔζגࣜձࣾ

    SRE/҆ୡ ྋ

    View full-size slide

  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(࠷৽)όʔδϣϯΞοϓͯ͠Έͯ


    ɾ·ͱΊ

    View full-size slide

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


    ࣗݾ঺հ

    View full-size slide

  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

    View full-size slide

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


    ͪͳΈʹ
    partᶃ

    View full-size slide

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


    ͪͳΈʹ partᶃ
    ɾSUPER STUDIO 2014~


    ɾCROਅ໺͞Μͱݩಉ྅


    ɾ౰࣌͸ecforceϦϦʔεͨ͠͹͔ͬ


    ɹɾΦϑΟε͸Ӭాொ


    ɾΤϯδχΞ͕͜Ε͔Βू·Δ࣌ظ


    ɾٕज़ϑΥϩʔ


    ɾPC௚͕֮ͯͨ͑͋͠Δ


    ɾݱࡏ͸CM·Ͱߦͳ͍ͬͯΔͷͰײಈ


    ɾҎલ͔Βษڧձ࣮ࢪ͔ͨͬͨ͠ʂ


    View full-size slide

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


    ͪͳΈʹ
    partᶄ
    MENTAͰ͸..

    View full-size slide

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


    ͪͳΈʹ partᶄ
    ɾΠϯϑϥ/αʔόʔ ίʔνϯά


    ɾMENTAϥϯΩϯά


    ɹɾ4Ґʂ


    ɾྦྷܭ189ਓʂ

    ɹɾۦ͚ग़͠ΤϯδχΞϑΥϩʔ


    ɹɾస৬࣮੷ଟ਺༗Γ

    View full-size slide

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


    όʔδϣϯΞοϓͷഎܠ

    View full-size slide

  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͕ϦϦʔε͞ΕΔ

    ɹɾ͕͢͞ʹةػײ


    ɾόʔδϣϯΞοϓΛܾߦʂʂ
    😇

    View full-size slide

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


    ֤αʔϏεͱ


    Deployαʔόʔͷ໾ׂʹ͍ͭͯ
    ͦͷલʹ

    View full-size slide

  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͢Δ༧ఆ


    View full-size slide

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


    CircleCI x Terraform

    View full-size slide

  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ʹؔͯ͠͸ϒϩάॻ͍͍ͯ·͢

    View full-size slide

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


    όʔδϣϯΞοϓͷྲྀΕ
    v0.12.29 → v0.15.0

    View full-size slide

  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ʹ͸্͛ΒΕͳ͍ʂ


    ঃʑʹࠩ෼Λͳ͍ͯ͘͜͠͏ʂ

    View full-size slide

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


    ΤϥʔରԠʹ͍ͭͯ
    Warning: Version constraints inside provider
    configuration blocks are deprecated

    View full-size slide

  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ʹҠߦ
    ͢Δ͜ͱͰղܾ


    View full-size slide

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


    ΤϥʔରԠʹ͍ͭͯ
    Error: Invalid resource instance data in state

    View full-size slide

  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ͭ͋ͬͨɹˠ


    View full-size slide

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


    .terraform.lock.hcl


    ʹ͍ͭͯ

    View full-size slide

  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Ͱόʔδϣϯ؅ཧ͢΂͖ͱهࡌ͞Ε͍ͯΔ


    ɹɾରԠࡁΈ

    View full-size slide

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


    CircleCI x Terraformͷ


    मਖ਼
    ࠷ޙʹ

    View full-size slide

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


    CircleCI x Terraformͷमਖ਼
    ɾ࠷ޙʹCircleCIͷdocker imagesΛมߋ


    ɾTerraform planͰࠩ෼͕Ͱͳ͍͜ͱΛ֬ೝ͢Δ


    ɾ࢒ΓͷϓϩδΣΫτ΋ಉ༷ʹߦ͏


    ɾ࡞ۀऴྃʂ

    View full-size slide

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


    v1.0.0(GA)ͷϦϦʔε
    ͱࢥ͍͖΍…

    View full-size slide

  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Λϕʔεʹ͍ͯ͠Δ


    ɹɾେ෯ͳมߋ͸ಛʹͳ͠


    ɹɾϒϩάॻ͍͍ͯΔͷͰࢀߟʹʂˠ

    View full-size slide

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


    v1.0.5ʹ


    όʔδϣϯΞοϓͯ͠Έͨ
    ͔ͤͬ͘ͳͷͰ

    View full-size slide

  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ʹࢦఆมߋ


    ɹɾࠩ෼मਖ਼


    View full-size slide

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


    v1.0.6ʂʁ
    ͱࢥ͍͖΍…9/4ʹͯ

    View full-size slide

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


    v1.0.6
    😇

    View full-size slide

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


    ·ͱΊ

    View full-size slide

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


    ·ͱΊ
    ɾ4ͭͷϓϩδΣΫτΛόʔδϣϯΞοϓͯ͠Έͯ


    ɹɾ͔ͳΓۤ௧


    ɹɾtfstateϑΝΠϧมߋʹ఍߅͕ͳ͘ͳͬͨ

    ɹɾͳΜͱ͔ͳΔ


    ɾτϥϒϧͳ͘ରԠͰ͖ͨ


    ɾTerraformͷplan΍apply͕ߴ଎Խ


    ɾࠓޙ͸සൟʹόʔδϣϯΞοϓ͍ͯ͘͠

    ɹɾ൒೥ʹҰճ(֮ޛΛ࣋ͬͯ)


    ɾv0.12ܥͰӡ༻͍ͯ͠Δํ͸͜ͷػձʹʂ


    ɹɾࠓͷ͏ͪʹόʔδϣϯΞοϓ͠ͳ͍ͱ௧͍໨ʹ͋͏

    View full-size slide

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


    ΤϯδχΞϒϩάͰ΋ެ։ͯ͠·͢



    https://engineer.blog.lancers.jp/2021/04/versionup-
    terraform/

    View full-size slide

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


    SREٻΉʂʂ



    SRE͕଍Γ·ͤΜ😇
    ࠷ۙΦϯϘʔσΟϯάͷࢿྉ࡞ͬͯΈ·ͨ͠

    View full-size slide

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


    View full-size slide