-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathcommon.tf
108 lines (93 loc) · 3.08 KB
/
common.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Configure the Microsoft Azure Provider
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
# use latest
#version = "=3.25.0"
}
}
}
provider "azurerm" {
/*subscription_id = var.azure.subscription_id
client_id = var.azure.client_id
client_secret = var.azure.client_secret
tenant_id = var.azure.tenant_id*/
features {}
}
# Create a resource group if it doesn’t exist
resource "azurerm_resource_group" "tfrg" {
name = "${var.resource.prefix}-rg"
location = var.resource.location
tags = {
environment = var.resource.tag
}
}
# Create virtual network
resource "azurerm_virtual_network" "tfvnet" {
name = "${var.resource.prefix}-vnet"
address_space = ["10.0.0.0/16"]
location = var.resource.location
resource_group_name = azurerm_resource_group.tfrg.name
tags = {
environment = var.resource.tag
}
}
resource "azurerm_subnet" "tfnatvnet" {
name = "app-natnet"
virtual_network_name = azurerm_virtual_network.tfvnet.name
resource_group_name = azurerm_resource_group.tfrg.name
address_prefixes = ["10.0.0.0/24"]
}
resource "azurerm_subnet" "tfwebvnet" {
name = "web-subnet"
virtual_network_name = azurerm_virtual_network.tfvnet.name
resource_group_name = azurerm_resource_group.tfrg.name
address_prefixes = ["10.0.1.0/24"]
}
resource "azurerm_subnet" "tfappvnet" {
name = "app-subnet"
virtual_network_name = azurerm_virtual_network.tfvnet.name
resource_group_name = azurerm_resource_group.tfrg.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_subnet" "tfjboxvnet" {
name = "jbox-subnet"
virtual_network_name = azurerm_virtual_network.tfvnet.name
resource_group_name = azurerm_resource_group.tfrg.name
address_prefixes = ["10.0.3.0/24"]
}
/*
# UDR
resource "azurerm_subnet_route_table_association" "tfappvnet" {
subnet_id = azurerm_subnet.tfappvnet.id
route_table_id = azurerm_route_table.nattable.id
}
resource "azurerm_route_table" "nattable" {
name = "${var.resource.prefix}-natroutetable"
location = var.resource.location
resource_group_name = azurerm_resource_group.tfrg.name
route {
name = "natrule1"
address_prefix = "0.0.0.0/0"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "10.0.0.10"
}
}
*/
# ASG
resource "azurerm_application_security_group" "tfwebasg" {
name = "tf-webasg"
location = azurerm_resource_group.tfrg.location
resource_group_name = azurerm_resource_group.tfrg.name
}
resource "azurerm_application_security_group" "tfjboxasg" {
name = "tf-jboxasg"
location = azurerm_resource_group.tfrg.location
resource_group_name = azurerm_resource_group.tfrg.name
}
resource "azurerm_application_security_group" "tfappasg" {
name = "tf-appasg"
location = azurerm_resource_group.tfrg.location
resource_group_name = azurerm_resource_group.tfrg.name
}