-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
44 lines (35 loc) · 1.77 KB
/
main.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
// Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
terraform {
required_version = ">= 0.12.0"
}
resource oci_core_vcn this {
dns_label = var.vcn_dns_label
cidr_block = var.vcn_cidr
compartment_id = var.compartment_ocid
display_name = var.vcn_display_name
}
resource oci_core_internet_gateway this {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.this.id
}
resource "oci_core_default_route_table" "this" {
manage_default_resource_id = oci_core_vcn.this.default_route_table_id
route_rules {
destination = "0.0.0.0/0"
network_entity_id = oci_core_internet_gateway.this.id
}
}
data "oci_identity_availability_domains" "this" {
compartment_id = var.compartment_ocid
}
resource "oci_core_subnet" "this" {
count = length(data.oci_identity_availability_domains.this.availability_domains)
availability_domain = lookup(data.oci_identity_availability_domains.this.availability_domains[count.index], "name")
cidr_block = cidrsubnet(var.vcn_cidr, ceil(log(length(data.oci_identity_availability_domains.this.availability_domains) * 2, 2)), count.index)
display_name = "Default Subnet ${lookup(data.oci_identity_availability_domains.this.availability_domains[count.index], "name")}"
dns_label = "${var.subnet_dns_label}${count.index + 1}"
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.this.id
security_list_ids = ["${oci_core_vcn.this.default_security_list_id}"]
}