๋ฐ์ํ
Terraform & Configuration file
- ํ
๋ผํผ์
IaC(Infra as a Code)Tool๋ก๊ตฌ์ฑ ํ์ผ(configuration file)์์ ์ธ์ (declarative)์ผ๋ก ์์ฑํจ์ผ๋ก์ ์ธํ๋ผ๋ฅผ ๊ด๋ฆฌ ํ ์ ์๊ฒ ํด์ค๋๋ค. - ๊ตฌ์ฑ ํ์ผ์ ํ ๋ผํผ์๊ฒ ์ค์นํ ํ๋ฌ๊ทธ์ธ, ์์ฑํ ์ธํ๋ผ, ๊ฐ์ ธ์ฌ ๋ฐ์ดํฐ ๋ฑ์ ์๋ ค์ค๋๋ค.
- ๊ตฌ์ฑ ํ์ผ์ ํ
๋ผํผ ๋ค์ดํฐ๋ธ ์ธ์ด์ธ
HCL(Hashicorp Configuration Language)๊ณผJSON์ผ๋ก ์์ฑ ํ ์ ์์ต๋๋ค. ๊ฐ๊ฐ.tf,.tf.json์ ํ์ฅ์๋ฅผ ๊ฐ์ผ๋ฉฐ ํ๋ฌธ(plain text)์ผ๋ก ์ ์ฅ๋ฉ๋๋ค. - ํ
๋ผํผ์
CDKTF(Cloud Development Kit for Terraform)์ ์ง์ํฉ๋๋ค. Typescript, Python, Java, Go, C#์ผ๋ก ์ธํ๋ผ๋ฅผ ์ ์ํ๋ฉด CDKTF๋ JSON์ผ๋ก ์์ฑ๋ ํ ๋ผํผ ๊ตฌ์ฑ ํ์ผ๋ก ๋ณํํฉ๋๋ค.
HCL(Hashicorp Configuration Language)
HCL์
Arguments์Blocks์ด๋ผ๋ 2๊ฐ์ง ์ค์ฌ ๊ตฌ๋ฌธ(key syntax)์ผ๋ก ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค.Arguments์ผ์ข ์ Attribute๋ฅผ ์๋ฏธํฉ๋๋ค.
image_id = "abc123"
Blocks๋ธ๋ญ์ ๋ค๋ฅธ ์ปจํ ์ธ ์ ์ปจํ ์ด๋๋ก
Blcok Type๊ณผ Block Type์ ๋ฐ๋ฅธBlock Label์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.๋ธ๋ญ์ ๋ณธ๋ฌธ(Block body)๋{,}๋ก ๊ตฌ๋ถ๋๋ฉฐ Arguments๊ณผ Blocks์ด ์ค์ฒฉ๋์ด ์์ ์ ์์ต๋๋ค.<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" { # Block body <IDENTIFIER> = <EXPRESSION> # Argument <NESTED BLOCK> { <IDENTIFIER> = <EXPRESSION> # Argument } }Block Type์
resource,data,provider,terraform,variable๋ฑ์ด ๋ ์ ์์ต๋๋ค.
Style Conventions
- ํ
๋ผํผ์ ๋ค๋ฅธ ์ฌ์ฉ์๊ฐ ์์ฑํ ํ์ผ์ด๋ ๋ชจ๋๊ด์ ์ผ๊ด์ฑ์ ์ํด ๊ถ์ฅ๋๋
์คํ์ผ ์ปจ๋ฒค์ (style conventions)์ด ์กด์ฌํฉ๋๋ค.terraform fmt๋ฅผ ์คํํ๋ฉด ์คํ์ผ ์ปจ๋ฒค์ ์ ์์ฝ๊ฒ ์ ์ฉํ ์ ์์ต๋๋ค.
์ฐธ๊ณ
๋ฐ์ํ
'๐ IaC > Terraform' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [Terraform] Variable ์ ๋ ฅ ๋ณ์ (0) | 2022.09.03 |
|---|---|
| [Terraform] Error: Incompatible provider version (0) | 2022.08.23 |
| [Terraform] Provider, Resource, Data Source, Variable, Output, Locals, Module (0) | 2022.08.11 |
| [TF] terraform์ผ๋ก aws ec2 ๋ง๋ค๊ธฐ (0) | 2021.11.05 |
| [IaC/TF] Terraform ์ค์น (0) | 2021.11.04 |