DBA Hub

📋Steps in this guide1/4

Terraform : Oracle Cloud Infrastructure (OCI) Virtual Cloud Network (VCN)

This article describes how to create a virtual cloud network (VCN) on Oracle Cloud Infrastructure (OCI) using Terraform.

oracle miscconfigurationintermediate
by OracleDba
14 views
1

Create Working Directory

Create a new working directory and switch to that directory. In a previous article ( here ) we discussed the creation of an OCI provider. Copy the OCI provider information into this new working directory.

Code/Command (click line numbers to comment):

1
2
3
4
5
mkdir \git\oraclebase\terraform\oci\oci_vcn
cd \git\oraclebase\terraform\oci\oci_vcn

copy \git\oraclebase\terraform\oci\oci_provider\*.tf .
copy \git\oraclebase\terraform\oci\oci_provider\*.tfvars .
2

oci_vcn.tf

Create a file called "oci_vcn.tf" with the following contents. The file begins with variable definitions. We could set default values for these variables, or use literal values directly in the provider definition, but we don't want sensitive information checked into version control, so it makes sense to separate out variable values from the script. The resources section defines the VCN, subnets and security lists using the input variables. Most of the definitions are defaults, but we've included an extra ingress rule for ports 1521-1522. The outputs section allows us to see information about the VCN, subnets and security lists that have been created, including the IDs. The variables, resources and outputs sections can be split into separate files if you find that organisation easier. It may help for more complex definitions.

Code/Command (click line numbers to comment):

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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Variables
variable "compartment_id"   { type = string }
variable "vcn_display_name" { type = string }
variable "vcn_dns_label"    { type = string }

variable "vnc_cidr_block" {
  type    = string
  default = "10.0.0.0/16"
}

variable "vnc_private_subnet_cidr_block" {
  type    = string
  default = "10.0.1.0/24"
}

variable "vnc_public_subnet_cidr_block" {
  type    = string
  default = "10.0.0.0/24"
}


# Modules and Resources
module "vcn"{
  source                   = "oracle-terraform-modules/vcn/oci"
  version                  = "2.0.0"
  
  # Required
  compartment_id           = var.compartment_id
  region                   = var.region
  vcn_name                 = var.vcn_display_name
  vcn_dns_label            = var.vcn_dns_label

  # Optional
  internet_gateway_enabled = true
  # Commented out for my free tier account.
  #nat_gateway_enabled      = true
  #service_gateway_enabled  = true
  vcn_cidr                 = var.vnc_cidr_block
}

resource "oci_core_subnet" "tf_vcn_private_subnet"{
  # Required
  compartment_id    = var.compartment_id
  vcn_id            = module.vcn.vcn_id
  cidr_block        = var.vnc_private_subnet_cidr_block

  # Optional
  route_table_id    = module.vcn.nat_route_id
  security_list_ids = [oci_core_security_list.tf_private_security_list.id]
  display_name      = "private-subnet"
}

resource "oci_core_subnet" "tf_vcn_public_subnet"{
  # Required
  compartment_id    = var.compartment_id
  vcn_id            = module.vcn.vcn_id
  cidr_block        = var.vnc_public_subnet_cidr_block

  # Optional
  route_table_id    = module.vcn.ig_route_id
  security_list_ids = [oci_core_security_list.tf_public_security_list.id]
  display_name      = "public-subnet"
}

resource "oci_core_security_list" "tf_private_security_list"{
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id
  display_name   = "security-list-for-private-subnet"

  egress_security_rules {
    stateless        = false
    destination      = "0.0.0.0/0"
    destination_type = "CIDR_BLOCK"
    protocol         = "all" 
  }

  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"

    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
      min = 22
      max = 22
    }
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
      code = 4
    } 
  }   
  
  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
    } 
  }
}

resource "oci_core_security_list" "tf_public_security_list"{
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id
  display_name   = "security-list-for-public-subnet"

  egress_security_rules {
    stateless        = false
    destination      = "0.0.0.0/0"
    destination_type = "CIDR_BLOCK"
    protocol         = "all" 
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
        min = 22
        max = 22
    }
  }

  # Example of adding ports 1521-1522.
  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
        min = 1521
        max = 1522
    }
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
      code = 4
    } 
  }   
  
  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
    } 
  }

}

resource "oci_core_dhcp_options" "tf_dhcp_options"{
  # Required
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id

  #Options for type are either "DomainNameServer" or "SearchDomain"
  options {
    type        = "DomainNameServer"  
    server_type = "VcnLocalPlusInternet"
  }
  
  # Optional
  display_name = "default-dhcp-options"
}


# Outputs
output "vcn_id" {
  value = module.vcn.vcn_id
}

output "private_security_list_id" {
  value = oci_core_security_list.tf_private_security_list.id
}

output "public_security_list_id" {
  value = oci_core_security_list.tf_public_security_list.id
}

output "private_subnet_id" {
  value = oci_core_subnet.tf_vcn_private_subnet.id
}

output "public_subnet_id" {
  value = oci_core_subnet.tf_vcn_public_subnet.id
}
3

oci_vcn_variables.auto.tfvars

There are a number of ways to supply values for input variables ( see here ). In this example we'll use a ".auto.tfvars" file. We won't check this script into version control as it contains sensitive information. Create a file called "oci_vcn_variables.auto.tfvars" with the following contents. Adjust the values to match your desired compartment details. The is the OCID of the compartment that will house the VCN. You must adjust it with a valid value from your Oracle Cloud account. You would not normally use the root compartment for this. You can get the ID of a compartment from your Oracle Cloud account as follows. - Top-Left Hamburger > Identity & Security > Compartments - Click on the compartment of interest. - Click the "Copy" link next to "OCID".

Code/Command (click line numbers to comment):

1
2
3
compartment_id   = "ocid1.compartment.oc1..aaaaaaaa..."
vcn_display_name = "obvcn2"
vcn_dns_label    = "obvcn2"
4

Build the OCI Virtual Cloud Network (VCN)

Initialize the working directory using the command. Use the command to test the execution plan. Use the command to create the OCI compartment. Check the Oracle Cloud account to see the new VCN in the compartment you chose. For more information see: - Terraform: Create a Virtual Cloud Network - oci_core_security_list - oci_core_subnet - oci_core_dhcp_options - Terraform : All Articles Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
terraform init

terraform plan
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # oci_core_dhcp_options.tf_dhcp_options will be created
  + resource "oci_core_dhcp_options" "tf_dhcp_options" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "default-dhcp-options"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + options {
          + custom_dns_servers  = []
          + search_domain_names = (known after apply)
          + server_type         = "VcnLocalPlusInternet"
          + type                = "DomainNameServer"
        }
    }

  # oci_core_security_list.tf_private_security_list will be created
  + resource "oci_core_security_list" "tf_private_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-private-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_security_list.tf_public_security_list will be created
  + resource "oci_core_security_list" "tf_public_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-public-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 1522
              + min = 1521
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_subnet.tf_vcn_private_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_private_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.1.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "private-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # oci_core_subnet.tf_vcn_public_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_public_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.0.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "public-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # module.vcn.oci_core_internet_gateway.ig[0] will be created
  + resource "oci_core_internet_gateway" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-gateway"
      + enabled        = true
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # module.vcn.oci_core_route_table.ig[0] will be created
  + resource "oci_core_route_table" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-route"
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + route_rules {
          + cidr_block        = (known after apply)
          + description       = (known after apply)
          + destination       = "0.0.0.0/0"
          + destination_type  = (known after apply)
          + network_entity_id = (known after apply)
        }
    }

  # module.vcn.oci_core_vcn.vcn will be created
  + resource "oci_core_vcn" "vcn" {
      + cidr_block               = "10.0.0.0/16"
      + cidr_blocks              = (known after apply)
      + compartment_id           = "ocid1.compartment.oc1..aaaaaaaa..."
      + default_dhcp_options_id  = (known after apply)
      + default_route_table_id   = (known after apply)
      + default_security_list_id = (known after apply)
      + defined_tags             = (known after apply)
      + display_name             = "obvcn2"
      + dns_label                = "obvcn2"
      + freeform_tags            = {
          + "environment" = "dev"
        }
      + id                       = (known after apply)
      + ipv6cidr_block           = (known after apply)
      + ipv6public_cidr_block    = (known after apply)
      + is_ipv6enabled           = (known after apply)
      + state                    = (known after apply)
      + time_created             = (known after apply)
      + vcn_domain_name          = (known after apply)
    }

Plan: 8 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + private_security_list_id = (known after apply)
  + private_subnet_id        = (known after apply)
  + public_security_list_id  = (known after apply)
  + public_subnet_id         = (known after apply)
  + vcn_id                   = (known after apply)

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # oci_core_dhcp_options.tf_dhcp_options will be created
  + resource "oci_core_dhcp_options" "tf_dhcp_options" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "default-dhcp-options"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + options {
          + custom_dns_servers  = []
          + search_domain_names = (known after apply)
          + server_type         = "VcnLocalPlusInternet"
          + type                = "DomainNameServer"
        }
    }

  # oci_core_security_list.tf_private_security_list will be created
  + resource "oci_core_security_list" "tf_private_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-private-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_security_list.tf_public_security_list will be created
  + resource "oci_core_security_list" "tf_public_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-public-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 1522
              + min = 1521
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_subnet.tf_vcn_private_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_private_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.1.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "private-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # oci_core_subnet.tf_vcn_public_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_public_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.0.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "public-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # module.vcn.oci_core_internet_gateway.ig[0] will be created
  + resource "oci_core_internet_gateway" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-gateway"
      + enabled        = true
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # module.vcn.oci_core_route_table.ig[0] will be created
  + resource "oci_core_route_table" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-route"
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + route_rules {
          + cidr_block        = (known after apply)
          + description       = (known after apply)
          + destination       = "0.0.0.0/0"
          + destination_type  = (known after apply)
          + network_entity_id = (known after apply)
        }
    }

  # module.vcn.oci_core_vcn.vcn will be created
  + resource "oci_core_vcn" "vcn" {
      + cidr_block               = "10.0.0.0/16"
      + cidr_blocks              = (known after apply)
      + compartment_id           = "ocid1.compartment.oc1..aaaaaaaa..."
      + default_dhcp_options_id  = (known after apply)
      + default_route_table_id   = (known after apply)
      + default_security_list_id = (known after apply)
      + defined_tags             = (known after apply)
      + display_name             = "obvcn2"
      + dns_label                = "obvcn2"
      + freeform_tags            = {
          + "environment" = "dev"
        }
      + id                       = (known after apply)
      + ipv6cidr_block           = (known after apply)
      + ipv6public_cidr_block    = (known after apply)
      + is_ipv6enabled           = (known after apply)
      + state                    = (known after apply)
      + time_created             = (known after apply)
      + vcn_domain_name          = (known after apply)
    }

Plan: 8 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + private_security_list_id = (known after apply)
  + private_subnet_id        = (known after apply)
  + public_security_list_id  = (known after apply)
  + public_subnet_id         = (known after apply)
  + vcn_id                   = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.vcn.oci_core_vcn.vcn: Creating...
module.vcn.oci_core_vcn.vcn: Creation complete after 1s [id=ocid1.vcn.oc1.uk-london-1.amaaaaaa...]
module.vcn.oci_core_internet_gateway.ig[0]: Creating...
oci_core_dhcp_options.tf_dhcp_options: Creating...
oci_core_security_list.tf_private_security_list: Creating...
oci_core_security_list.tf_public_security_list: Creating...
module.vcn.oci_core_internet_gateway.ig[0]: Creation complete after 0s [id=ocid1.internetgateway.oc1.uk-london-1.aaaaaaaaa...]
module.vcn.oci_core_route_table.ig[0]: Creating...
oci_core_security_list.tf_private_security_list: Creation complete after 1s [id=ocid1.securitylist.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_private_subnet: Creating...
oci_core_security_list.tf_public_security_list: Creation complete after 1s [id=ocid1.securitylist.oc1.uk-london-1.aaaaaaaa...]
oci_core_dhcp_options.tf_dhcp_options: Creation complete after 1s [id=ocid1.dhcpoptions.oc1.uk-london-1.aaaaaaaa...]
module.vcn.oci_core_route_table.ig[0]: Creation complete after 1s [id=ocid1.routetable.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_public_subnet: Creating...
oci_core_subnet.tf_vcn_private_subnet: Creation complete after 3s [id=ocid1.subnet.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_public_subnet: Creation complete after 4s [id=ocid1.subnet.oc1.uk-london-1.aaaaaaaag...]

Apply complete! Resources: 8 added, 0 changed, 0 destroyed.

Outputs:

private_security_list_id = "ocid1.securitylist.oc1.uk-london-1.aaaaaaaa..."
private_subnet_id = "ocid1.subnet.oc1.uk-london-1.aaaaaaaa..."
public_security_list_id = "ocid1.securitylist.oc1.uk-london-1.aaaaaaaa..."
public_subnet_id = "ocid1.subnet.oc1.uk-london-1.aaaaaaaa..."
vcn_id = "ocid1.vcn.oc1.uk-london-1.amaaaaaa..."

Comments (0)

Please to add comments

No comments yet. Be the first to comment!