배포 계획
구조: Hub-Spoke 네트워크 모델
- Hub: 공통 인프라 구성 (VPN Gateway, Firewall 등)
- Spoke: 업무별 구분된 네트워크 (Web, WAS, DB 등 리소스 배치)
보안 구성
- NSG (Network Security Group): 각 Spoke VNet 및 서브넷에 할당
- VPN Gateway: Hub VNet에 배치
- Firewall: Hub VNet에 배치 및 UDR과 연동
리소스 그룹 구조
- RG-NETWORK – 가상 네트워크 및 서브넷 등 네트워크 리소스
- RG-SECURITY – NSG, Firewall, VPN 등 보안 리소스
- RG-COMPUTE – 가상 머신 등 컴퓨트 리소스
- RG-STORAGE – Storage Account 등 저장소 리소스
Tag 구성
- Key : Value 예시
- ResourceName : vm-web-prd-01 등
- ServiceType : WEB, WAS, DB 등
- Environment : PRD, QA, DEV
- DeploymentDate : 2025-05-07 등
1. VPN 모듈
- main.tf
module "vpn" {
source = "./modules/vpn"
vpn_gateways = {
hub = {
name = "hub-vpn-gw"
location = var.location
resource_group_name = module.resource_groups.resource_group_names["security"]
subnet_id = module.subnet.subnet_ids["gateway"]
public_ip_name = "hub-vpn-pip"
public_ip_sku = "Standard"
allocation_method = "Static"
vpn_type = "RouteBased"
sku = "VpnGw1"
}
}
}
- 모듈 main.tf
variable "vpn_gateways" {
description = "Map of VPN Gateway configurations"
type = map(object({
name = string
location = string
resource_group_name = string
subnet_id = string
public_ip_name = string
public_ip_sku = string
allocation_method = string
vpn_type = string
sku = string
}))
default = {}
}
resource "azurerm_public_ip" "vpn_pip" {
for_each = var.vpn_gateways
name = each.value.public_ip_name
resource_group_name = each.value.resource_group_name
location = each.value.location
allocation_method = each.value.allocation_method
sku = each.value.public_ip_sku
}
resource "azurerm_virtual_network_gateway" "vpn_gw" {
for_each = var.vpn_gateways
name = each.value.name
location = each.value.location
resource_group_name = each.value.resource_group_name
type = "Vpn"
vpn_type = each.value.vpn_type
sku = each.value.sku
ip_configuration {
name = "vpn-gw-ipconf"
public_ip_address_id = azurerm_public_ip.vpn_pip[each.key].id
subnet_id = each.value.subnet_id
private_ip_address_allocation = "Dynamic"
}
enable_bgp = false
}
# output "vpn_gateway_ids" {
# value = { for k, v in azurerm_virtual_network_gateway.vpn_gw : k => v.id }
# }
terraform validate를 통해 설정 유효성 검사
terraform plan을 통해 리소스 생성 계획 확인
terraform apply -auto-approve (yes 자동 입력 )
'Cloud > AZURE' 카테고리의 다른 글
Azure Policy 정리 (1) | 2025.06.10 |
---|---|
Terraform on Azure [모듈화] - (6) Firewall & UDR 모듈 (1) | 2025.05.22 |
Terraform on Azure [모듈화] - (4) VM & NSG 모듈 (1) | 2025.05.22 |
Terraform on Azure [모듈화] - (3) network 모듈 (1) | 2025.05.22 |
Terraform on Azure [모듈화] - (2) VS Code 기본 설정 (0) | 2025.05.20 |