Skip to content

Commit

Permalink
fix route tables with drg destination (#81)
Browse files Browse the repository at this point in the history
* WIP - fix route tables with drg destination

* fix route tables with drg destination

* fixed typo and added links to drg submodule documentation
  • Loading branch information
snafuz authored Mar 18, 2022
1 parent c20b1be commit e7d3a9d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ It creates the following resources:
* An optional internet gateway and a route table
* An optional NAT gateway and a route table
* An optional service gateway
* An optional dynamic routing gateway
* An optional remote peering connection
* An optional dynamic routing gateway _[Deprecated; use the [drg submodule](modules/drg/README.md) instead]_
* An optional remote peering connection _[Deprecated; use the [drg submodule](modules/drg/README.md) instead]_
* One or more optional Local Peering Gateways in requestor or acceptor mode, and possibilities to associate a Route Table
It also controls the Default Security List, with a *Lockdown mode* that can be enabled or disabled
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ It creates the following resources:
* An optional internet gateway and a route table
* An optional NAT gateway
* An optional service gateway
* An optional dynamic routing gateway
* An optional remote peering connection
* An optional dynamic routing gateway _[Deprecated; use [drg submodule](modules/drg/README.md) instead]_
* An optional remote peering connection _[Deprecated; use [drg submodule](modules/drg/README.md) instead]_
* One or more optional Local Peering Gateways in requestor or acceptor mode, and possibilities to associate a Route Table

It also controls the Default Security List, with a *Lockdown mode* that can be enabled or disabled.
Expand Down
5 changes: 3 additions & 2 deletions examples/drg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ module "vcn_spokes" {
for_each = var.vcn_spokes

# general oci parameters
compartment_id = var.compartment_id
label_prefix = var.label_prefix
compartment_id = var.compartment_id
label_prefix = var.label_prefix
attached_drg_id = module.drg_hub.drg_id

# vcn parameters
create_internet_gateway = each.value["create_internet_gateway"] # boolean: true or false
Expand Down
7 changes: 4 additions & 3 deletions examples/rpc/rpc_from_drg_module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module "vcn_acceptor" {
compartment_id = var.compartment_id
label_prefix = var.label_prefix
freeform_tags = var.freeform_tags
defined_tags = var.defined_tags
defined_tags = var.defined_tags

# vcn parameters
create_drg = false #! deprecated inner drg, use drg-module instead
Expand All @@ -35,12 +35,13 @@ module "vcn_acceptor" {
vcn_cidrs = var.vcn_cidrs_acceptor
vcn_dns_label = "vcnacceptor"
vcn_name = "vcn-rpc-acceptor"
attached_drg_id = module.drg_acceptor.drg_id

nat_gateway_route_rules = [for cidr in var.vcn_cidrs_requestor :
{
destination = cidr # set requestor vcn cidr as destination cidr
destination_type = "CIDR_BLOCK"
network_entity_id = module.drg_acceptor.drg_id
network_entity_id = "drg"
description = "Terraformed - User added Routing Rule to requestor VCN through DRG"
}
]
Expand Down Expand Up @@ -121,7 +122,7 @@ module "vcn_requestor" {
{
destination = cidr # set acceptor vcn cidr as destination cidr
destination_type = "CIDR_BLOCK"
network_entity_id = module.drg_requestor.drg_id
network_entity_id = "drg"
description = "Terraformed - User added Routing Rule to acceptor VCN through DRG"
}
]
Expand Down
7 changes: 3 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ output "vcn_id" {
}

output "drg_id" {
#! deprecation notice: this output will be removed at next major release
description = "Deprecated: Use drg sub-module instead. id of drg if it is created"
value = join(",", module.drg_from_vcn_module[*].drg_id)
description = "id of the attached drg"
value = var.create_drg ? join(",", module.drg_from_vcn_module[*].drg_id) : var.attached_drg_id
}

output "rpc_id" {
description = "id of rpc if it is created"
value = join(",", module.drg_from_vcn_module[*].rpc_id)
value = var.create_drg ? join(",", module.drg_from_vcn_module[*].rpc_id) : ""
}

output "nat_gateway_id" {
Expand Down
4 changes: 4 additions & 0 deletions terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ freeform_tags = {
defined_tags = {
"Operations.CostCenter" = "42"
}

#ID of the DRG attached to the VCN
attached_drg_id = ""

# # custom routing rules variable declaration example

# internet_gateway_route_rules = [ # this module input shows how to pass routing information to the vcn module inline, directly on the vcn module block
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,9 @@ variable "nat_gateway_route_rules" {
type = list(map(string))
default = null
}

variable "attached_drg_id" {
description = "the ID of DRG attached to the VCN"
type = string
default = ""
}
4 changes: 2 additions & 2 deletions vcn_gateways.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "oci_core_route_table" "ig" {
content {
destination = route_rules.value.destination
destination_type = route_rules.value.destination_type
network_entity_id = module.drg_from_vcn_module[0].drg_id
network_entity_id = var.create_drg ? module.drg_from_vcn_module[0].drg_id : var.attached_drg_id
description = route_rules.value.description
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ resource "oci_core_route_table" "nat" {
content {
destination = route_rules.value.destination
destination_type = route_rules.value.destination_type
network_entity_id = module.drg_from_vcn_module[0].drg_id
network_entity_id = var.create_drg ? module.drg_from_vcn_module[0].drg_id : var.attached_drg_id
description = route_rules.value.description
}
}
Expand Down

0 comments on commit e7d3a9d

Please sign in to comment.