-
Notifications
You must be signed in to change notification settings - Fork 2
/
vpc.tf
125 lines (112 loc) · 3.47 KB
/
vpc.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
resource "ibm_is_vpc" "vpc" {
address_prefix_management = "manual"
default_routing_table_name = "rt-${var.vpc_name}"
name = var.vpc_name
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
}
resource "ibm_is_vpc_address_prefix" "vpc_address_prefix_zone_1" {
cidr = var.cidr_zone_1
name = "ap-${ibm_is_vpc.vpc.name}-zone-1"
vpc = ibm_is_vpc.vpc.id
zone = local.zone_1
}
resource "ibm_is_vpc_address_prefix" "vpc_address_prefix_zone_2" {
cidr = var.cidr_zone_2
name = "ap-${ibm_is_vpc.vpc.name}-zone-2"
vpc = ibm_is_vpc.vpc.id
zone = local.zone_2
}
resource "ibm_is_vpc_address_prefix" "vpc_address_prefix_zone_3" {
cidr = var.cidr_zone_3
name = "ap-${ibm_is_vpc.vpc.name}-zone-3"
vpc = ibm_is_vpc.vpc.id
zone = local.zone_3
}
resource "ibm_is_public_gateway" "vpc_public_gateway_zone_1" {
name = "${ibm_is_vpc.vpc.name}-pg-1"
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_1
}
resource "ibm_is_public_gateway" "vpc_public_gateway_zone_2" {
name = "${ibm_is_vpc.vpc.name}-pg-2"
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_2
}
resource "ibm_is_public_gateway" "vpc_public_gateway_zone_3" {
name = "${ibm_is_vpc.vpc.name}-pg-3"
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_3
}
resource "ibm_is_subnet" "vpc_subnet_default_1" {
ipv4_cidr_block = var.subnet_default_zone_1
name = "${ibm_is_vpc.vpc.name}-sn-1"
public_gateway = ibm_is_public_gateway.vpc_public_gateway_zone_1.id
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_1
}
resource "ibm_is_subnet" "vpc_subnet_default_2" {
ipv4_cidr_block = var.subnet_default_zone_2
name = "${ibm_is_vpc.vpc.name}-sn-2"
public_gateway = ibm_is_public_gateway.vpc_public_gateway_zone_2.id
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_2
}
resource "ibm_is_subnet" "vpc_subnet_default_3" {
ipv4_cidr_block = var.subnet_default_zone_3
name = "${ibm_is_vpc.vpc.name}-sn-3"
public_gateway = ibm_is_public_gateway.vpc_public_gateway_zone_3.id
resource_group = data.ibm_resource_group.default.id
tags = ["schematics"]
vpc = ibm_is_vpc.vpc.id
zone = local.zone_3
}
resource "ibm_is_network_acl" "acl_default" {
name = "acl-${ibm_is_vpc.vpc.name}"
resource_group = data.ibm_resource_group.default.id
rules {
action = "allow"
destination = "0.0.0.0/0"
direction = "inbound"
icmp {
code = 1
type = 1
}
name = "inbound"
source = "0.0.0.0/0"
}
rules {
action = "allow"
destination = "0.0.0.0/0"
direction = "outbound"
icmp {
code = 1
type = 1
}
name = "outbound"
source = "0.0.0.0/0"
}
vpc = ibm_is_vpc.vpc.id
}
resource "ibm_is_subnet_network_acl_attachment" "acl_attachment_subnet_1" {
subnet = ibm_is_subnet.vpc_subnet_default_1.id
network_acl = ibm_is_network_acl.acl_default.id
}
resource "ibm_is_subnet_network_acl_attachment" "acl_attachment_subnet_2" {
subnet = ibm_is_subnet.vpc_subnet_default_2.id
network_acl = ibm_is_network_acl.acl_default.id
}
resource "ibm_is_subnet_network_acl_attachment" "acl_attachment_subnet_3" {
subnet = ibm_is_subnet.vpc_subnet_default_3.id
network_acl = ibm_is_network_acl.acl_default.id
}