๐Ÿ“‚ IaC/Terraform

[Terraform] Provider

dhyuck 2022. 9. 9. 00:10
๋ฐ˜์‘ํ˜•

Provider์™€ Provider maintainer

  • Terraform์€ Provider๋ผ๊ณ  ํ•˜๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ํ†ตํ•ด ํด๋ผ์šฐ๋“œ ์ œ๊ณต์ž(AWS, GCP, โ€ฆ)๋‚˜ ๊ธฐํƒ€ ์„œ๋น„์Šค์™€ ์ƒํ˜ธ ์ž‘์šฉํ•ฉ๋‹ˆ๋‹ค.

  • Provider๋Š” ์ปดํ“จํŒ… ๋จธ์‹ , ์„œ๋ธŒ๋„ท, ์Šคํ† ๋ฆฌ์ง€์™€ ๊ฐ™์€ ๋ฆฌ์†Œ์Šค๋ฅผ ๊ฐœ๋ณ„ ๋‹จ์œ„๋กœ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

  • Provider maintainer๋Š” ํด๋ผ์šฐ๋“œ ์ œ๊ณต์ž๋‚˜ ๊ธฐํƒ€ ์„œ๋น„์Šค์˜ API๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด provider๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

  • Terraform Registry์—์„œ Provider๋“ค์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ์ง์ ‘ ์ž‘์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.


Providr ๋ฒ„์ „ ๊ด€๋ฆฌ

  • Provider ๋ฒ„์ „์„ ์ ์ ˆํžˆ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๋ฒ„์ „ ์ œ์•ฝ ์กฐ๊ฑด ๋‚ด์—์„œ ์ตœ์‹  ๋ฒ„์ „์„ ๋‹ค์šด๋กœ๋“œํ•˜๋ฉฐ ์ด๋กœ ์ธํ•ด ์˜ˆ์ƒํ•˜์ง€ ๋ชปํ•œ ์ธํ”„๋ผ ๋ณ€๊ฒฝ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์—ฌ๋Ÿฌ ์‚ฌ์šฉ์ž๊ฐ€ ๋™์ผํ•œ Terraform Configuration์„ ๊ด€๋ฆฌํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ, ๋ชจ๋‘๊ฐ€ ๋™์ผํ•œ ๋ฒ„์ „์˜ Provider๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • configuration์—์„œ provider ๋ฒ„์ „์„ ๊ด€๋ฆฌํ•˜๋Š” 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•

    • terraform block์—์„œ required_providers์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒ„์ „ ์ง€์ •
    • VCS ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— dependency lock file(.terraform.lock.hcl)์„ ์—…๋กœ๋“œํ•˜์—ฌ ๋ฒ„์ „์„ ์ž ๊ธˆ
  • .terraform.lock.hcl : ํ…Œ๋ผํผ ๋ฒ„์ „ 1.1 ์ด์ƒ์—์„œ init์‹œ์— ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ๋กœ provider ๋ฒ„์ „์„ ์ž ๊ธˆํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” lock file

  • workspace๋ฅผ initํ•  ๋•Œ dependency lock file์ด ์žˆ๋‹ค๋ฉด lock file์— ์ง€์ •๋œ provider ๋ฒ„์ „์„ ์„ค์น˜ํ•˜๊ณ , ์—†๋‹ค๋ฉด required_providers ๋ธ”๋ก์— ์ง€์ •๋œ ๋ฒ„์ „์„ ์„ค์น˜ํ•œ๋‹ค.


Provider ๋ฒ„์ „ ์—…๊ทธ๋ ˆ์ด๋“œ

  • terraform init -upgrade

    ๋ชจ๋“  provider๋ฅผ ์ง€์ •๋œ ๋ฒ„์ „ ์ œ์•ฝ ์กฐ๊ฑด ๋‚ด์—์„œ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ ํ•ฉ๋‹ˆ๋‹ค. configuration ๋‚ด์˜ ๋ฒ„์ „ ์ œ์•ฝ ์กฐ๊ฑด์ด ํ˜„์žฌ ๋ฒ„์ „๋ณด๋‹ค ๋” ๋‚ฎ๋‹ค๋ฉด ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.


๋ฐ˜์‘ํ˜•