networking: calculate subnet cidr from vcn
add a missing vcn attribute add subnet cidr outputs remove a placeholder comment
This commit is contained in:
parent
a0e732cda2
commit
9377d43630
|
@ -1,10 +1,11 @@
|
||||||
resource "oci_core_vcn" "vcn" {
|
resource "oci_core_vcn" "vcn" {
|
||||||
compartment_id = oci_identity_compartment.compartment.id
|
compartment_id = oci_identity_compartment.compartment.id
|
||||||
cidr_block = var.vcn_cidr
|
cidr_block = var.vcn_cidr
|
||||||
is_ipv6enabled = var.enable_ipv6
|
is_ipv6enabled = var.enable_ipv6
|
||||||
display_name = join("", [var.prefix, "vcn"])
|
is_oracle_gua_allocation_enabled = true
|
||||||
dns_label = local.vcn_dns_label
|
display_name = join("", [var.prefix, "vcn"])
|
||||||
freeform_tags = local.freeform_tags
|
dns_label = local.vcn_dns_label
|
||||||
|
freeform_tags = local.freeform_tags
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "oci_core_internet_gateway" "igw" {
|
resource "oci_core_internet_gateway" "igw" {
|
||||||
|
@ -48,7 +49,6 @@ resource "oci_core_default_security_list" "default" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# oci_core_network_security_group
|
|
||||||
resource "oci_core_network_security_group" "default" {
|
resource "oci_core_network_security_group" "default" {
|
||||||
compartment_id = oci_identity_compartment.compartment.id
|
compartment_id = oci_identity_compartment.compartment.id
|
||||||
vcn_id = oci_core_vcn.vcn.id
|
vcn_id = oci_core_vcn.vcn.id
|
||||||
|
@ -77,13 +77,15 @@ resource "oci_core_network_security_group_security_rule" "default" {
|
||||||
protocol = try(each.value.protocol, "all")
|
protocol = try(each.value.protocol, "all")
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "oci_core_subnet" "public_subnet" {
|
resource "oci_core_subnet" "public" {
|
||||||
compartment_id = oci_identity_compartment.compartment.id
|
compartment_id = oci_identity_compartment.compartment.id
|
||||||
vcn_id = oci_core_vcn.vcn.id
|
vcn_id = oci_core_vcn.vcn.id
|
||||||
cidr_block = var.vcn_cidr
|
cidr_block = cidrsubnets(oci_core_vcn.vcn.cidr_blocks[0], 8)[0]
|
||||||
display_name = "public"
|
ipv6cidr_block = var.enable_ipv6 ? cidrsubnets(oci_core_vcn.vcn.ipv6cidr_blocks[0], 8)[0] : null
|
||||||
dns_label = "public"
|
display_name = "public"
|
||||||
route_table_id = oci_core_default_route_table.default.id
|
dns_label = "public"
|
||||||
security_list_ids = [oci_core_default_security_list.default.id]
|
availability_domain = null
|
||||||
freeform_tags = merge(local.freeform_tags, { type = "public" })
|
route_table_id = oci_core_default_route_table.default.id
|
||||||
|
security_list_ids = [oci_core_default_security_list.default.id]
|
||||||
|
freeform_tags = merge(local.freeform_tags, { type = "public" })
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,16 @@ output "vcn_ipv6_cidr_private_blocks" {
|
||||||
value = oci_core_vcn.vcn.ipv6private_cidr_blocks
|
value = oci_core_vcn.vcn.ipv6private_cidr_blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "subnet_cidr_block" {
|
||||||
|
description = "The CIDR block for the subnet"
|
||||||
|
value = oci_core_subnet.public.cidr_block
|
||||||
|
}
|
||||||
|
|
||||||
|
output "subnet_ipv6_cidr_block" {
|
||||||
|
description = "The IPv6 CIDR block for the subnet"
|
||||||
|
value = oci_core_subnet.public.ipv6cidr_block
|
||||||
|
}
|
||||||
|
|
||||||
output "ssh_key_public" {
|
output "ssh_key_public" {
|
||||||
description = "The public SSH key for the compute instances"
|
description = "The public SSH key for the compute instances"
|
||||||
value = local.compute_ssh_key
|
value = local.compute_ssh_key
|
||||||
|
|
Loading…
Reference in New Issue
Block a user