๐ํ ๋ผํผ ๋ชจ๋์ด๋?
https://developer.hashicorp.com/terraform/tutorials/modules/module
Modules overview | Terraform | HashiCorp Developer
Read about how Terraform modules make configuration easier to organize, understand, reuse, and share. Learn about the directory structure of a module, and how to call them.
developer.hashicorp.com
ํ ๋ผํผ ๋ชจ๋์ ๋จ์ผ ๋๋ ํ ๋ฆฌ์ ์๋ ํ ๋ผํผ ๊ตฌ์ฑ ํ์ผ ์ธํธ์ด๋ค. ๋จ์ผ ๋๋ ํ ๋ฆฌ์ ํ๋ ์ด์์ .tf ํ์ผ๋ก ๊ตฌ์ฑ๋ ๊ฐ๋จํ ๊ตฌ์ฑ๋ ๋ชจ๋์ด๋ค. ์ด๋ฌํ ๋๋ ํ ๋ฆฌ์์ ์ง์ ํ ๋ผํผ ๋ช ๋ น์ ์คํํ๋ฉด ๋ฃจํธ ๋ชจ๋๋ก ๊ฐ์ฃผ๋๋ค. ๋ฐ๋ผ์ ๋ชจ๋ ํ ๋ผํผ ๊ตฌ์ฑ์ ๋ชจ๋์ ์ผ๋ถ์ด๋ค. ๋ค์๊ณผ ๊ฐ์ ๊ฐ๋จํ ๊ตฌ์ฑ ํ์ผ ์ธํธ๋ฅผ ๊ฐ์ง ์ ์๋ค.
.
โโโ LICENSE
โโโ README.md
โโโ main.tf
โโโ variables.tf
โโโ outputs.tf
๐๋ชจ๋์ ์ ํ์ํ๊ฐ?
ํ ๋ผํผ ๋ชจ๋์ ์ธํ๋ผ ๊ตฌ์ฑ์ ๋ณต์ก์ฑ์ ์ค์ด๊ณ , ์ผ๊ด์ฑ๊ณผ ์ฌ์ฌ์ฉ์ฑ์ ๋์ฌ์ฃผ๋ ์ค์ํ ๋๊ตฌ์ด๋ค. ๋ค์๊ณผ ๊ฐ์ ๋ฌธ์ ๋ค์ ํด๊ฒฐํ๋ ๋ฐ ๋์์ด ๋๋ค.
- ๊ตฌ์ฑ์ ๋ฆฌ: ๊ตฌ์ฑ์ ๋ ผ๋ฆฌ์ ์ธ ๋จ์๋ก ๋๋์ด ๊ด๋ จ๋ ๋ฆฌ์์ค๋ฅผ ํจ๊ป ๊ด๋ฆฌํ ์ ์๋๋ก ๋์์ค. ์๋ฐฑ~์์ฒ ์ค์ ์ฝ๋๋ฅผ ๊ตฌ์ฑํ ๋ ํนํ ์ ์ฉ.
- ๊ตฌ์ฑ ์บก์ํ: ์๋ก ๋ค๋ฅธ ๊ตฌ์ฑ ์์๋ฅผ ๋ถ๋ฆฌํด ์๊ธฐ์น ์์ ์ํฅ์ด๋ ์ค์๋ฅผ ๋ฐฉ์งํ ์ ์์.
- ๊ตฌ์ฑ ์ฌ์ฌ์ฉ: ํ ๋ฒ ์์ฑํ ์ฝ๋๋ฅผ ์ฌ๋ฌ ๊ณณ์์ ์ฌ์ฌ์ฉํ ์ ์์ด ์๊ฐ๊ณผ ๋ ธ๋ ฅ์ ์ ์ฝํ ์ ์๊ณ , ํ์ ๊ฐ ๋๋ ์ปค๋ฎค๋ํฐ ๊ฐ ๊ณต์ ๋ ๊ฐ๋ฅ.
- ์ผ๊ด์ฑ๊ณผ ๋ชจ๋ฒ ์ฌ๋ก ์ ์ฉ: ๋ณต์กํ ์ค์ ์ ์ผ๊ด๋๊ฒ ์ ์งํ๊ณ , ๋ณด์ ๋ฑ ์ค์ํ ์ค์ ์ ์ค์ ์์ด ์ ์ฉํ ์ ์๋๋ก ๋์์ค.
- ์ ํ ์๋น์ค ์ ๊ณต: ๋ค๋ฅธ ํ์ด ๋ชจ๋์ ์ฝ๊ฒ ์ฌ์ฉํ๊ฒ ํ์ฌ, ์ธํ๋ผ ๊ตฌ์ฑ์ ์ต์ํ์ง ์์ ํ๋ ์กฐ์ง์ ์ ์ฑ ์ ๋ง๋ ์ธํ๋ผ๋ฅผ ์ง์ ๋ง๋ค ์ ์๊ฒ ํด์ค.
๐๋ก์ปฌ๊ณผ ์๊ฒฉ ๋ชจ๋
๋ชจ๋์ ๋ก์ปฌ ํ์ผ ์์คํ ์ด๋ ์๊ฒฉ ์์ค์์ ๋ถ๋ฌ์ฌ ์ ์๋ค. ํ ๋ผํผ์ ๋ค์ํ ์๊ฒฉ ์์ค๋ฅผ ์ง์ํ๋ค.
- Terraform Registry
- ๋๋ถ๋ถ์ ๋ฒ์ ๊ด๋ฆฌ ์์คํ (์: GitHub, GitLab ๋ฑ)
- HTTP URL
- HCP Terraform ๋๋ Terraform Enterprise์ ํ๋ผ์ด๋น ๋ชจ๋ ๋ ์ง์คํธ๋ฆฌ
๋ชจ๋์ ์ง์ ์์ฑํด ๋ก์ปฌ์์ ๋ถ๋ฌ์ฌ ์๋ ์๊ณ , ๋ค๋ฅธ ์ฌ๋์ด ๋ง๋ ๋ชจ๋์ ์๊ฒฉ ์ ์ฅ์์์ ๊ฐ์ ธ์ ์ฌ์ฉํ ์๋ ์๋ค.
๐๋ชจ๋ ์์ฑ
https://developer.hashicorp.com/terraform/tutorials/modules/module-create
Build and use a local module | Terraform | HashiCorp Developer
Write a local module to create an Amazon S3 bucket hosting a static website. Create a module directory, write the module configuration, variables, and outputs, and call the module from a root configuration.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/modules/pattern-module-creation
Module creation - recommended pattern | Terraform | HashiCorp Developer
Learn the architectural recommendations for module creation distilled from engagements with large enterprises using Terraform. Use Terraform module best practices to scope, build, improve and consume Terraform modules.
developer.hashicorp.com
ํ ๋ผํผ ๋ชจ๋์ ์ผ๋ฐ์ ์ผ๋ก ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ๋ก ๊ด๋ฆฌ๋๋ค.
modules/
โโโ example-module/
โโโ main.tf # ๋ฆฌ์์ค ์ ์ - ์ค์ ์ธํ๋ผ ๋ฆฌ์์ค๋ฅผ ์ ์
โโโ variables.tf # ์
๋ ฅ ๋ณ์ ์ ์ - ์ฌ์ฉ์๋ก๋ถํฐ ์
๋ ฅ๋ฐ์ ๋ณ์ ์ ์ธ
โโโ outputs.tf # ์ถ๋ ฅ ๋ณ์ ์ ์ - ๋ชจ๋ ์ฌ์ฉ์๊ฐ ์ฌ์ฉํ ์ ์๋๋ก ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅ
โ ํ ๋ผํผ ๋ชจ๋ ์์ฑ ์ํฌํ๋ก์ฐ
- ์๊ตฌ ์ฌํญ์ ์ ์ ํ ๋ชจ๋๋ก ๋๋๋ค.
- ๋ชจ๋์ ํ๋์ ๋ช ํํ ๋ชฉ์ ์ ๊ฐ๊ณ , ์๊ณ ๋จ์ํ๊ฒ ์์ํ๋ ๊ฒ์ด ์ข๋ค.
- ์ธ ๊ฐ์ง ๊ธฐ์ค์ ๊ณ ๋ คํด ์ธํ๋ผ๋ฅผ ๊ทธ๋ฃนํ
- ์บก์ํ - ํญ์ ํจ๊ป ๋ฐฐํฌ๋๋ ์ธํ๋ผ๋ ํ๋์ ๋ชจ๋๋ก ๋ฌถ๊ธฐ. ๊ทธ๋ฌ๋ ๋๋ฌด ๋ง์ ๋ฆฌ์์ค๋ฅผ ํ ๋ชจ๋์ ๋ด์ผ๋ฉด ์ดํดํ๊ธฐ ์ด๋ ค์์ง.
- ๊ถํ ๊ฒฝ๊ณ - ์๋ก ๋ค๋ฅธ ์กฐ์ง/ํ์ด ์ฑ ์์ง๋ ๋ฆฌ์์ค๋ฅผ ํ ๋ชจ๋์ ๋ฃ์ง ๋ง๊ธฐ. ๋ณด์๊ณผ ๊ถํ ๋ถ๋ฆฌ๋ฅผ ์ ์งํด์ผ ํจ.
- ๋ณ๋์ฑ - ์์ฃผ ๋ณ๊ฒฝ๋๋ ๋ฆฌ์์ค์ ์ ๋ณ๊ฒฝ๋์ง ์๋ ๋ฆฌ์์ค๋ ๋ถ๋ฆฌ. ์ํ๋ฅผ ๋ณด์กดํด์ผ ํ๋ ๋ฆฌ์์ค๋ฅผ ๋ถํ์ํ ๋ณ๊ฒฝ์ผ๋ก๋ถํฐ ๋ณดํธ.
- ๋ชจ๋ MVP๋ฅผ ๋ง๋ ๋ค.
- ์ฒ์๋ถํฐ ์๋ฒฝํ ๋ชจ๋์ ๋ง๋ค๋ ค๊ณ ํ์ง ์์๋ ๊ด์ฐฎ๋ค.
- MVP ์ค๊ณ ์ ์ ์์ฌํญ
- ํฌ๊ทํ ์์ธ ์ผ์ด์ค๋ ํฌํจํ์ง ๋ง ๊ฒ.
- ์กฐ๊ฑด๋ฌธ์ ๊ฐ๋ฅํ ํผํ๊ณ , ๋จ์ํ ๊ตฌ์กฐ ์ ์ง
- ๊ผญ ํ์ํ ๋ณ์๋ง ๋ ธ์ถ
- ์ถ๋ ฅ๊ฐ์ ์ต๋ํ ๋ง์ด ํฌํจํ ๊ฒ.
์ถํ ์์ฑ ์์ ์ถ๊ฐ ์์
'Cloud > IaC' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[IaC] ํ ๋ผํผ(Terraform)์ด๋? (0) | 2025.06.28 |
---|