refactor: 구조 변경

This commit is contained in:
donghyeon-ka
2026-08-28 17:24:26 +09:00
parent a6f6c663e0
commit b8626946b1
192 changed files with 2251 additions and 206 deletions
+24
View File
@@ -0,0 +1,24 @@
# Infrastructure Components
작고 응집된 재사용 단위를 둡니다.
예:
```text
components/
├── aws/
│ ├── network/
│ ├── identity/
│ └── eks/
├── gcp/
│ ├── network/
│ └── gke/
└── shared/
└── naming/
```
실제로 사용하는 provider 경로만 만듭니다. component에는 environment backend,
실제 credential과 환경 고유 값을 두지 않습니다. 입력, 출력, version constraint,
권한 요구 사항과 사용 예를 component README에 기록합니다.
새 component는 `_template`을 복사해 시작합니다.
@@ -0,0 +1,29 @@
# __REPLACE_ME_COMPONENT_NAME__
## 책임
이 component가 생성하고 소유하는 리소스를 적습니다.
## 입력
필수/선택 입력과 민감 정보 여부를 적습니다.
## 출력
다른 component 또는 live root에 제공하는 안정적인 contract를 적습니다.
## 요구 권한
plan/apply에 필요한 최소 provider 권한을 적습니다.
## 사용 예
실제 credential, account ID와 운영 값을 포함하지 않는 호출 예를 적습니다.
## 구현 체크리스트
- [ ] backend를 선언하지 않는다.
- [ ] provider/version constraint를 명시한다.
- [ ] 입력 validation과 민감 output 표시를 추가한다.
- [ ] 환경 이름을 내부에 하드코딩하지 않는다.
- [ ] README와 테스트를 함께 갱신한다.
@@ -0,0 +1,16 @@
# Vault Kubernetes roles
## 책임
Vault Kubernetes auth role을 입력 map에서 생성하는 backend 없는 재사용
Terraform component입니다.
## 입력과 출력
- 입력: auth backend 경로와 role별 audience, ServiceAccount, namespace,
policy, TTL
- 출력: 없음
- 민감 payload: 없음
호출하는 live root가 provider와 state를 소유합니다. 이 component는 환경
이름이나 credential을 내부에 저장하지 않습니다.
@@ -0,0 +1,11 @@
resource "vault_kubernetes_auth_backend_role" "this" {
for_each = var.roles
audience = one(each.value.audiences)
backend = var.backend
bound_service_account_names = each.value.service_account_names
bound_service_account_namespaces = each.value.service_account_namespaces
role_name = each.key
token_policies = each.value.token_policies
token_ttl = each.value.token_ttl
}
@@ -0,0 +1,15 @@
variable "backend" {
description = "Kubernetes auth backend path."
type = string
}
variable "roles" {
description = "Kubernetes auth roles keyed by Vault role name."
type = map(object({
audiences = set(string)
service_account_names = set(string)
service_account_namespaces = set(string)
token_policies = set(string)
token_ttl = number
}))
}
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.11.0"
required_providers {
vault = {
source = "hashicorp/vault"
version = "~> 5.7.0"
}
}
}
@@ -0,0 +1,15 @@
# Vault policy set
## 책임
이름과 HCL 문서 map을 Vault ACL policy로 만드는 backend 없는 재사용
Terraform component입니다.
## 입력과 출력
- 입력: policy 이름별 HCL 문서
- 출력: 요청 이름별 생성된 Vault policy 이름
- 민감 payload: 없음
Policy 문서는 이를 소비하는 live root가 소유하며, 이 component는 API 객체
생성만 캡슐화합니다.
@@ -0,0 +1,11 @@
resource "vault_policy" "this" {
for_each = var.policies
name = each.key
policy = each.value
}
output "names" {
description = "Policy names keyed by their requested names."
value = { for name, policy in vault_policy.this : name => policy.name }
}
@@ -0,0 +1,4 @@
variable "policies" {
description = "Map of Vault policy names to HCL policy documents."
type = map(string)
}
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.11.0"
required_providers {
vault = {
source = "hashicorp/vault"
version = "~> 5.7.0"
}
}
}