Skip to content

Commit 2b6580f

Browse files
committed
terraform/OCI: Add a default VCN
The kdevops set-up for other cloud providers assumes that kdevops will provision a VCN/subnet for use during test runs. OCI does not have that option; it assumes that a long-lived subnet already exists to which kdevops instances should be attached. In a moment I will introduced a Kconfig option to use network resources that kdevops manages instead of a pre-existing subnet. This patch adds those resources, but does not yet use them, so that the new network resource configuration can be reviewed easily. Reviewed-by: Luis Chamberlain <[email protected]> Reviewed-by: Chandan Babu R <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent b7495a8 commit 2b6580f

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

terraform/oci/main.tf

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,115 @@ module "volumes" {
5151
vol_volume_count = var.oci_volumes_per_instance
5252
vol_volume_size = var.oci_volumes_size
5353
}
54+
55+
resource "oci_core_vcn" "kdevops_vcn" {
56+
cidr_blocks = [
57+
"10.0.0.0/16",
58+
]
59+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
60+
display_name = "kdevops VCN"
61+
dns_label = "kdevops"
62+
is_ipv6enabled = false
63+
}
64+
65+
resource "oci_core_internet_gateway" "kdevops_internet_gateway" {
66+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
67+
display_name = "kdevops internet gateway"
68+
vcn_id = oci_core_vcn.kdevops_vcn.id
69+
}
70+
71+
resource "oci_core_dhcp_options" "kdevops_dhcp_options" {
72+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
73+
display_name = "kdevops dhcp options"
74+
vcn_id = oci_core_vcn.kdevops_vcn.id
75+
76+
options {
77+
type = "DomainNameServer"
78+
server_type = "VcnLocalPlusInternet"
79+
}
80+
options {
81+
type = "SearchDomain"
82+
search_domain_names = ["kdevops.oraclevcn.com"]
83+
}
84+
}
85+
86+
resource "oci_core_route_table" "kdevops_route_table" {
87+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
88+
display_name = "kdevops route table"
89+
vcn_id = oci_core_vcn.kdevops_vcn.id
90+
route_rules {
91+
destination = "0.0.0.0/0"
92+
destination_type = "CIDR_BLOCK"
93+
network_entity_id = oci_core_internet_gateway.kdevops_internet_gateway.id
94+
}
95+
}
96+
97+
resource "oci_core_security_list" "kdevops_security_list" {
98+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
99+
display_name = "kdevops security list"
100+
vcn_id = oci_core_vcn.kdevops_vcn.id
101+
102+
egress_security_rules {
103+
description = "Allow all outbound traffic"
104+
destination = "0.0.0.0/0"
105+
destination_type = "CIDR_BLOCK"
106+
protocol = "all"
107+
stateless = false
108+
}
109+
110+
ingress_security_rules {
111+
description = "Enable Path MTU Discovery to work"
112+
icmp_options {
113+
code = 4
114+
type = 3
115+
}
116+
protocol = 1
117+
source = "0.0.0.0/0"
118+
source_type = "CIDR_BLOCK"
119+
stateless = false
120+
}
121+
ingress_security_rules {
122+
description = "Allow applications within VCN to fail fast"
123+
icmp_options {
124+
type = 3
125+
}
126+
protocol = 1
127+
source = "10.0.0.0/16"
128+
source_type = "CIDR_BLOCK"
129+
stateless = false
130+
}
131+
ingress_security_rules {
132+
description = "Enable instance management via Ansible"
133+
protocol = 6
134+
source = "0.0.0.0/0"
135+
source_type = "CIDR_BLOCK"
136+
stateless = false
137+
tcp_options {
138+
min = 22
139+
max = 22
140+
}
141+
}
142+
ingress_security_rules {
143+
description = "Allow VCN-local TCP traffic for ports: all"
144+
protocol = 6
145+
source = "10.0.0.0/16"
146+
source_type = "CIDR_BLOCK"
147+
stateless = false
148+
tcp_options {
149+
min = 1
150+
max = 65535
151+
}
152+
}
153+
}
154+
155+
resource "oci_core_subnet" "kdevops_subnet" {
156+
availability_domain = data.oci_identity_availability_domain.kdevops_av_domain.name
157+
cidr_block = "10.0.0.0/24"
158+
compartment_id = data.oci_identity_compartments.kdevops_compartment.compartments[0].id
159+
dhcp_options_id = oci_core_dhcp_options.kdevops_dhcp_options.id
160+
dns_label = "runners"
161+
display_name = "kdevops subnet"
162+
route_table_id = oci_core_route_table.kdevops_route_table.id
163+
security_list_ids = ["${oci_core_security_list.kdevops_security_list.id}"]
164+
vcn_id = oci_core_vcn.kdevops_vcn.id
165+
}

0 commit comments

Comments
 (0)