배포 계획
구조: 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 등
NSG.tf
- 앞서 배포해본 VM 1대에 대핸 NSG 생성
- azurerm_linux_virtual_machine 리소스는 NSG를 자동으로 생성하지 않음. 포탈에서 VM을 만들 때만 NSG가 자동으로 생성되므로, NSG.tf와 충돌하지는 않는다고함
# NSG 생성
resource "azurerm_network_security_group" "web_prd_nsg" {
name = "nsg-prd-web-01"
location = var.location
resource_group_name = azurerm_resource_group.compute_rg.name
security_rule {
name = "Allow-HTTP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "Allow-HTTPS"
priority = 110
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}
tags = {
ResourceName = "nsg-prd-web-01"
ServiceType = "WEB"
Environment = "PRD"
DeploymentDate = "2025-05-07"
}
}
# NIC에 NSG 연결
resource "azurerm_network_interface_security_group_association" "web_prd_nsg_assoc" {
network_interface_id = azurerm_network_interface.web_prd_nic.id
network_security_group_id = azurerm_network_security_group.web_prd_nsg.id
}
- az account show로 현재 구독 위치 확인
- terraform validate를 통해 설정 유효성 검사
- terraform plan을 통해 리소스 생성 계획 확인
- terraform apply로 적용 (yes 입력)
- 결과 확인
'Cloud > AZURE' 카테고리의 다른 글
Terraform on Azure 정리 (8) - Azure 배포 테스트 : VPN (끝) (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 |