배포 계획
구조: 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 등
VPN.tf
- network.tf에서 배포한 RG, Subnet 활용
resource "azurerm_public_ip" "vpn_pip" {
name = "hub-vpn-pip"
resource_group_name = azurerm_resource_group.security_rg.name
location = azurerm_resource_group.security_rg.location
allocation_method = "Static"
sku = "Standard" # VPN Gateway는 반드시 Standard SKU 사용
}
resource "azurerm_virtual_network_gateway" "hub_vpn_gw" {
name = "hub-vpn-gw"
location = azurerm_resource_group.security_rg.location
resource_group_name = azurerm_resource_group.security_rg.name
type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
ip_configuration {
name = "vpn-gw-ipconf"
public_ip_address_id = azurerm_public_ip.vpn_pip.id
subnet_id = azurerm_subnet.hub_gateway_subnet.id
private_ip_address_allocation = "Dynamic"
# 일반적으로 Azure VPN private_ip_address_allocation 은 "Dynamic"만 허용된다고함
}
enable_bgp = false
}
- az account show로 현재 구독 위치 확인
- (terraform init -upgrade로 Azure 공급자(provider)를 다운로드)
- terraform validate를 통해 설정 유효성 검사
- terraform plan을 통해 리소스 생성 계획 확인
- terraform apply로 적용 (yes 입력)
- 결과 확인
최종 결과 정리
terraform state list
# Terraform 상태 파일에 등록된 모든 리소스의 목록
배포한 서비스 목록
가상 네트워크 (VNet) | dev_vnet, hub_vnet, prd_vnet |
서브넷 (Subnet) | dev_subnet_web, prd_subnet_web, prd_subnet_db, hub_firewall_subnet, hub_gateway_subnet |
네트워크 보안 그룹 (NSG) | web_prd_nsg |
방화벽 (Firewall) | hub_fw |
VPN 게이트웨이 (VPN Gateway) | hub_vpn_gw |
Public IP | firewall_pip, vpn_pip, web_prd_public_ip |
리소스 그룹 (Resource Group) | RG-NETWORK (네트워크 리소스), RG-SECURITY (보안 리소스), RG-COMPUTE (컴퓨트 리소스), RG-STORAGE (저장소 리소스) |
라우팅 (Routing) | prd_web_to_fw_route, prd_web_route_table |
네트워크 피어링 (VNet Peering) | dev_to_hub, hub_to_dev, hub_to_prd, prd_to_hub |
terraform show
# 생성된 리소스의 상세 정보
'Cloud > AZURE' 카테고리의 다른 글
Terraform on Azure 정리 (6) - Azure 배포 테스트 : NSG (0) | 2025.05.08 |
---|---|
Terraform on Azure 정리 (7) - Azure 배포 테스트 : Firewall & UDR (0) | 2025.05.08 |
Terraform on Azure 정리 (5) - Azure 배포 테스트 : VM (0) | 2025.05.08 |
Terraform on Azure 정리 (4) - Azure 배포 테스트 : Network (0) | 2025.05.07 |
Terraform on Azure 정리 (3) - tf 파일과 기본 명령어 (0) | 2025.05.07 |