ISMS-P 2.8.6์ ์ ๊ท ๋์ ยท๊ฐ๋ฐ ๋ฐ ๋ณ๊ฒฝ๋ ์์คํ ์ ์ด์ํ๊ฒฝ์ผ๋ก ์์ ํ๊ฒ ์ด๊ดํ๋๋ก ์๊ตฌํฉ๋๋ค. ํด๋ผ์ฐ๋ ํ๊ฒฝ์์๋ Workspace ๋ถ๋ฆฌ์ CI/CD ์น์ธ ๊ฒ์ดํธ๋ฅผ ํตํด ์์ ํ ์ด๊ด ์ฒด๊ณ๋ฅผ ๊ตฌ์ถํด์ผ ํฉ๋๋ค.
ISMS-P 2.8.6 ์ด์ํ๊ฒฝ ์ด๊ด ์๊ตฌ์ฌํญ
"์ ๊ท ๋์ ยท๊ฐ๋ฐ ๋ฐ ๋ณ๊ฒฝ๋ ์์คํ ์ ์ด์ํ๊ฒฝ์ผ๋ก ์์ ํ๊ฒ ์ด๊ดํ๊ธฐ ์ํ ํต์ ์ ์ฐจ๋ฅผ ์๋ฆฝยท์ดํํ์ฌ์ผ ํ๋ค."
์ด์ํ๊ฒฝ ์ด๊ด ๋ฏธํก์ผ๋ก ๋ฐ์ํ ์ค์ ์ฌ๊ณ
ํ๋ก์๋ก๊ทธ์จ ์ ๋ก๋ฐ์ด ์ทจ์ฝ์ ํจ์น๊ฐ ๋ฐฐํฌ๋์์ผ๋, ์ด์ ์ค๋จ ์ฐ๋ ค๋ก ์ด๊ดํ์ง ์๋ค๊ฐ ํดํน ํผํด ๋ฐ์. ํจ์น ์ด๊ด์ ๋ฏธ๋ฃจ๋ ๋์ ๊ณต๊ฒฉ์๊ฐ ์ทจ์ฝ์ ์ ์ ์ฉํ์ต๋๋ค.
๐ก ๊ตํ: ๋ณด์ ํจ์น ์ ์ ์ด๊ด ํ์, ์๋ํ๋ ๋ฐฐํฌ ํ์ดํ๋ผ์ธ ๊ตฌ์ถ
ํด๋ผ์ฐ๋ ์คํ ๋ฆฌ์ง ์ด๊ด ์ ์ ๊ทผ ๊ถํ ์ค์ ์ค๋ฅ๋ก 'Public Read' ์ํ๋ก ๋ฐฐํฌ๋์ด 2,600๋ง ๊ฑด์ ์ด๋ ฅ์๊ฐ ์ธ๋ถ์ ๋ ธ์ถ๋์์ต๋๋ค. ์ด๊ด ์ ๋ณด์ ์ค์ ๊ฒ์ฆ์ด ์์๋ ๊ฒ์ด ์์ธ์ ๋๋ค.
๐ก ๊ตํ: ์ด์ํ๊ฒฝ ์ด๊ด ์ ๋ณด์ ์ค์ ๊ฒ์ฆ ํ์, Policy as Code ์๋ ๊ฒ์ฆ
ํ๊ฒฝ ๋ฏธ๋ถ๋ฆฌ ๋ฐ ์น์ธ ์๋ ๋ฐฐํฌ์ ์ํ์ฑ
# ๋จ์ผ Workspace์์ ๋ชจ๋ ํ๊ฒฝ ๊ด๋ฆฌ (์ํ!)
terraform {
cloud {
organization = "my-company"
workspaces {
name = "all-environments" # ๊ตฌ๋ถ ์์!
}
}
}
# ํ๊ฒฝ ๊ตฌ๋ถ ์์ด ํ๋์ฝ๋ฉ (์ํ!)
resource "aws_instance" "web" {
instance_type = "t3.large" # prod๊ฐ dev์๋ ์ ์ฉ
}
# ์น์ธ ์์ด ์ง์ ๋ฐฐํฌ (์ํ!)
# terraform apply -auto-approve
๋จ์ผ Workspace์์ ๋ชจ๋ ํ๊ฒฝ ๊ด๋ฆฌ ์ ์ค์๋ก ์ด์ํ๊ฒฝ ๋ณ๊ฒฝ ์ํ
# ํ๊ฒฝ๋ณ Workspace ๋ถ๋ฆฌ
terraform {
cloud {
organization = "my-company"
workspaces {
tags = ["app:web-service"]
# web-service-dev
# web-service-staging
# web-service-prod
}
}
}
# ํ๊ฒฝ ๋ณ์๋ก ๋ถ๊ธฐ
resource "aws_instance" "web" {
instance_type = var.instance_type
tags = { Environment = var.environment }
}
ํ๊ฒฝ๋ณ Workspace ๋ถ๋ฆฌ๋ก ์์ ํ ์ด๊ด ์ฒด๊ณ ๊ตฌ์ถ
๊ฐ๋ฐ/ํ ์คํธ/์ด์ ํ๊ฒฝ ๋ถ๋ฆฌ ๋ฏธํก
์ด์ํ๊ฒฝ ์ด๊ด ์น์ธ ์ ์ฐจ ์์
์ด๊ด ์คํจ ์ Rollback ์ฒด๊ณ ๋ถ์ฌ
ํ๊ฒฝ๋ณ ์ค์ ๊ด๋ฆฌ ๋ฏธํก
IaC ์ ์ ๋ถ์ ๊ธฐ๋ฐ ํ๊ฒฝ ๋ถ๋ฆฌ ๊ฒ์ฆ
# OPA/Rego Policy - ํ๊ฒฝ ๋ถ๋ฆฌ ๊ฒ์ฆ
package terraform.environment_migration
deny[msg] {
workspace := input.workspace.name
not contains(workspace, "-dev")
not contains(workspace, "-staging")
not contains(workspace, "-prod")
msg := "Workspace ์ด๋ฆ์ ํ๊ฒฝ ๊ตฌ๋ถ ํ์ (-dev/-staging/-prod)"
}
deny[msg] {
resource := input.resource_changes[_]
resource.change.actions[_] == "create"
not resource.change.after.tags.Environment
msg := sprintf("๋ฆฌ์์ค %s์ Environment ํ๊ทธ ํ์ - ISMS-P 2.8.6", [resource.address])
}
# prod ํ๊ฒฝ ์ง์ ๋ฐฐํฌ ๋ฐฉ์ง
deny[msg] {
workspace := input.workspace.name
contains(workspace, "-prod")
input.run.auto_apply == true
msg := "Production ํ๊ฒฝ auto-apply ๊ธ์ง - ์๋ ์น์ธ ํ์"
}
Runtime ํ์ง ๋ฐ ์ด๊ด ์ ์ฐจ ๋ชจ๋ํฐ๋ง
# GitHub Actions - ํ๊ฒฝ๋ณ ์น์ธ ๊ฒ์ดํธ
name: Terraform Deployment
jobs:
deploy-dev:
runs-on: ubuntu-latest
environment: development # ์๋ ์น์ธ
steps:
- name: Deploy to Dev
run: terraform apply -auto-approve
deploy-staging:
needs: deploy-dev
runs-on: ubuntu-latest
environment: staging # ์๋ ์น์ธ ํ์
steps:
- name: Deploy to Staging
run: terraform apply staging.tfplan
deploy-prod:
needs: deploy-staging
runs-on: ubuntu-latest
environment: production # ์๋ ์น์ธ + ์ถ๊ฐ ๊ฒํ ์
steps:
- name: Deploy to Production
run: terraform apply prod.tfplan
์ฆ์ ์ ์ฉ ๊ฐ๋ฅํ ๊ถ์ฅ ์ค์
# Terraform Cloud - ํ๊ฒฝ๋ณ Workspace ๋ถ๋ฆฌ
terraform {
cloud {
organization = "my-company"
workspaces {
tags = ["app:web-service"]
# dev, staging, prod ๋ณ๋ Workspace ์์ฑ
# web-service-dev, web-service-staging, web-service-prod
}
}
}
# ํ๊ฒฝ ๋ณ์ ์ ์
variable "environment" {
description = "Deployment environment"
type = string
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Environment must be dev, staging, or prod."
}
}
# ํ๊ฒฝ๋ณ ๋ฆฌ์์ค ์ค์
resource "aws_instance" "web" {
ami = data.aws_ami.amazon_linux.id
instance_type = var.instance_type # ํ๊ฒฝ๋ณ tfvars์์ ์ ์
tags = {
Name = "web-${var.environment}"
Environment = var.environment
ISMS-P = "2.8.6"
}
}
environment = "dev"
instance_type = "t3.micro"
min_instances = 1
environment = "staging"
instance_type = "t3.small"
min_instances = 2
environment = "prod"
instance_type = "t3.large"
min_instances = 3
๐ก ํต์ฌ: Terraform Cloud Workspace๋ฅผ ํ๊ฒฝ๋ณ(dev/staging/prod)๋ก ๋ถ๋ฆฌํ๊ณ , ๊ฐ ํ๊ฒฝ์ ๋ณ๋์ tfvars ํ์ผ๋ก ์ค์ ๊ด๋ฆฌํฉ๋๋ค. staging๊ณผ production ๋ฐฐํฌ ์ Manual Approve ํ์.
ISMS-P ์ฌ์ฌ ์ฆ์ ๋ฐ ์ ๊ธฐ ๋ณด๊ณ
| ์ ๊ฒ ํญ๋ชฉ | ์ฆ์ ์๋ฃ |
|---|---|
| ํ๊ฒฝ ๋ถ๋ฆฌ | Terraform Cloud Workspace ๋ชฉ๋ก |
| ์น์ธ ์ ์ฐจ | CI/CD ํ์ดํ๋ผ์ธ ์ค์ , ์น์ธ ๋ก๊ทธ |
| Rollback ์ฒด๊ณ | S3 State ๋ฒ์ ์ด๋ ฅ, ๋ณต๊ตฌ ํ ์คํธ |
| ๋ณ๊ฒฝ ์ด๋ ฅ | Terraform Cloud Run History |
| ์ด๊ด ๋ฌธ์ํ | ๋ณ๊ฒฝ์์ ์์ฒญ์, ๊ฒฐ๊ณผ์ |
# Terraform Cloud API๋ก Workspace ๋ชฉ๋ก
curl -H "Authorization: Bearer $TFE_TOKEN" \
"https://app.terraform.io/api/v2/\
organizations/my-org/workspaces"
# Run History ์กฐํ
curl -H "Authorization: Bearer $TFE_TOKEN" \
"https://app.terraform.io/api/v2/\
workspaces/{id}/runs"
# State ๋ฒ์ ์ด๋ ฅ ํ์ธ
aws s3api list-object-versions \
--bucket terraform-state \
--prefix production/
# GitHub Environment ์น์ธ ์ค์
gh api repos/{owner}/{repo}/environments
๊ธฐ์กด ๋๊ตฌ๊ฐ ๋์น๋ ์ ๊ฒ ์์ญ
๋ฆฌ์์ค ํ๊ทธ ํ์ธ ์์ค
Environment ํ๊ทธ ์กด์ฌ ์ฌ๋ถํ๊ณ: Workspace ๋ถ๋ฆฌ ์ํ ๊ฒ์ฆ ๋ถ๊ฐ, CI/CD ์น์ธ ์ ์ฐจ ํ์ธ ๋ถ๊ฐ, Rollback ์ฒด๊ณ ์ ๋ฌด ํ์ธ ๋ถ๊ฐ
Terraform Cloud API + CI/CD ์ฐ๋ + State ๋ถ์
์ฐจ๋ณ์ : ์ด๊ด ์ ์ฐจ ์ ์ฒด ์๋ํ + Rollback ์ฒด๊ณ ๊ฒ์ฆ์ผ๋ก ํ์ง โ ์กฐ์น โ ์ฆ์ ์ ๊ณผ์ ์๋ํ