-
Notifications
You must be signed in to change notification settings - Fork 71
Add IPv6 Support #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add IPv6 Support #140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,31 +4,42 @@ | |
resource "oci_core_vcn" "vcn" { | ||
# We still allow module users to declare a cidr using `vcn_cidr` instead of the now recommended `vcn_cidrs`, but internally we map both to `cidr_blocks` | ||
# The module always use the new list of string structure and let the customer update his module definition block at his own pace. | ||
cidr_blocks = var.vcn_cidrs[*] | ||
compartment_id = var.compartment_id | ||
display_name = var.label_prefix == "none" ? var.vcn_name : "${var.label_prefix}-${var.vcn_name}" | ||
dns_label = var.vcn_dns_label | ||
is_ipv6enabled = var.enable_ipv6 | ||
cidr_blocks = var.vcn_cidrs[*] | ||
compartment_id = var.compartment_id | ||
display_name = var.label_prefix == "none" ? var.vcn_name : "${var.label_prefix}-${var.vcn_name}" | ||
dns_label = var.vcn_dns_label | ||
is_ipv6enabled = var.enable_ipv6 | ||
is_oracle_gua_allocation_enabled = var.enable_ipv6 ? var.vcn_is_oracle_gua_allocation_enabled : null | ||
ipv6private_cidr_blocks = var.enable_ipv6 ? var.vcn_ipv6private_cidr_blocks : null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm willing to make a breaking change and release a new major version so we can handle this better:
Or something along that line i.e. don't make the parameters gouge the eyes of developers who are going to use them. Since we are thinking of making a breaking change, consider renaming other variables accordingly. |
||
|
||
dynamic "byoipv6cidr_details" { | ||
for_each = var.enable_ipv6 ? var.vcn_byoipv6cidr_details : [] | ||
content { | ||
byoipv6range_id = byoipv6cidr_details.value.byoipv6range_id | ||
ipv6cidr_block = byoipv6cidr_details.value.ipv6cidr_block | ||
} | ||
} | ||
|
||
freeform_tags = var.freeform_tags | ||
defined_tags = var.defined_tags | ||
|
||
lifecycle { | ||
ignore_changes = [defined_tags, dns_label, freeform_tags] | ||
ignore_changes = [defined_tags, dns_label, freeform_tags, is_ipv6enabled, is_oracle_gua_allocation_enabled] | ||
} | ||
} | ||
|
||
#Module for Subnet | ||
module "subnet" { | ||
source = "./modules/subnet" | ||
|
||
compartment_id = var.compartment_id | ||
tenancy_id = var.tenancy_id | ||
subnets = var.subnets | ||
enable_ipv6 = var.enable_ipv6 | ||
vcn_id = oci_core_vcn.vcn.id | ||
ig_route_id = var.create_internet_gateway ? oci_core_route_table.ig[0].id : null | ||
nat_route_id = var.create_nat_gateway ? oci_core_route_table.nat[0].id : null | ||
compartment_id = var.compartment_id | ||
tenancy_id = var.tenancy_id | ||
subnets = local.enriched_subnets | ||
enable_ipv6 = var.enable_ipv6 | ||
vcn_id = oci_core_vcn.vcn.id | ||
ig_route_id = var.create_internet_gateway ? oci_core_route_table.ig[0].id : null | ||
nat_route_id = var.create_nat_gateway ? oci_core_route_table.nat[0].id : null | ||
igw_ngw_mixed_route_id = var.enable_ipv6 && var.create_internet_gateway && var.create_nat_gateway ? oci_core_route_table.igw_ngw_mixed_route_id[0].id : null | ||
|
||
freeform_tags = var.freeform_tags | ||
|
||
|
@@ -41,6 +52,17 @@ locals { | |
subnet = { | ||
for key, value in var.subnets : key => contains(keys(value), "name") ? value.name : key | ||
} | ||
|
||
subnet_ipv6_cidr_blocks = var.enable_ipv6 ? { | ||
for key, value in var.subnets : key => contains(keys(value), "ipv6cidr_blocks") ? | ||
{ "ipv6cidr_blocks" : [for entry in value["ipv6cidr_blocks"] : length(regexall("^\\d+,[ ]?\\d+$", entry)) > 0 ? cidrsubnet(coalesce([for cidr in oci_core_vcn.vcn.ipv6cidr_blocks : cidr]...), tonumber(split(",", entry)[0]), tonumber(trim(split(",", entry)[1], " "))) : entry] } : | ||
{ "ipv6cidr_blocks" : [] } | ||
} : {} | ||
|
||
enriched_subnets = { for k, v in var.subnets : | ||
k => merge(v, lookup(local.subnet_ipv6_cidr_blocks, k, null)) | ||
} | ||
|
||
service_logdef = { for k in local.subnet : format("%s_%s", k, "log") => { loggroup = "loggrp", service = "flowlogs", resource = k } } | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does gua stand for something?