1. terraform provider ์์ฑ
- ๋๋ ํ ๋ฆฌ ์์ฑ
- provider.tf, s3.tf ํ์ผ ์์ฑ
- provider.tf์ ์๋ ๊ตฌ๋ฌธ ์ถ๊ฐ(IAM ์ธ์ฆ)
provider "aws" {
access_key = "<AWS Access Key ID>"
secret_key = "<AWS Secrey Key>"
region = "ap-northeast-2"
}
- s3.tf์ ์๋ ๊ตฌ๋ฌธ ์ถ๊ฐ(S3 bucket ์์ฑ)
resource "aws_s3_bucket" "s3" {
bucket = "eunhye-bucket-0225"
acl = "private"
}
2. terraform init
- Terraform ์ด๊ธฐํ
- ํ์ผ ๋ฆฌ์คํธ
3. terraform plan
- ๋ฐฐํฌํ Resource ํ์ธ(์ถ๊ฐํ Resoucre๋ +๋ก ํ๊ธฐ)
4. terraform apply
- Resource๋ฅผ AWS(provider.tf ์ค์ ๋ AWS ๊ณ์ )๋ก ๋ฐฐํฌ
- AWS Console - S3์์ terraform์ผ๋ก ์์ฑ๋ bucket ํ์ธ ๊ฐ๋ฅ
- s3.tf๋ฅผ ์์๋ก ๋ค๋ฅธ ๋๋ ํ ๋ฆฌ๋ก ์ด๋
- ์ฌ๋ผ์ง Resoucre๋ -๋ก ํ๊ธฐ
- ๋ค์ s3.tf๋ฅผ ๊ฐ์ง๊ณ ์ค๊ฒ๋๋ฉด "No changes"๋ก ํ๊ธฐ
5. terraform destory
- ๋ฐฐํฌ๋ Resource ์ญ์
- AWS Console - S3์์ ์ญ์ ๋ bucket ํ์ธ ๊ฐ๋ฅ
'Devops' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
terraform ๋ฒ์ ๊ด๋ฆฌ : tfenv (0) | 2021.10.03 |
---|---|
Config ์๋ํ ํด(puppet, chef, salt, ansible) (0) | 2021.04.13 |
AWS CDK ์ฌ์ฉ๋ฒ (0) | 2021.03.20 |
Infrastructure as Code(IaC) (0) | 2021.03.20 |
Git ์ฌ์ฉ๋ฒ (0) | 2021.01.11 |