-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At this stage, drg sub-module is a the same level of features than before refactor implementation fully backward compatible. * feat(drg): arguments provider parity - all arguments available on oci provider for oci_core_drg are supported by the module - all attributes are accessible through drg_all_attributes ouput * feat(drg): add vcn attachment * feat(drg): add support for route tables definition VCN attachments are regrouped under one oci_core_drg_attachment resource, taking a map(any) as input from var.drg_vcn_attachments. This new map allows to define two route tables: - drg_route_table_id to control routing inside the drg - vcn_transit_routing_id to control transit routing on the vcn attachment Other attachment types will generate distinct oci_core_drg_attachment resources. add a new drg_summary output that combine drg name, drg id and vcn attachments. other minor changes: - make vcn_name and vcn_dns_label optional inputs - add feature to disable vcn dns fix: #46 , #66
- Loading branch information
Showing
21 changed files
with
556 additions
and
112 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Creating a DRG | ||
|
||
[docs/prerequisites]:https://github.com/oracle-terraform-modules/terraform-oci-vcn/blob/main/docs/prerequisites.adoc | ||
[Provisioning Infrastructure with Terraform]:https://www.terraform.io/docs/cli/run/index.html | ||
|
||
This example illustrates how to use submodule `drg` from `terraform-oci-vcn` module to create a DRG. Use this example if you need to create a DRG independently from a VCN. | ||
|
||
<!-- insert list of created resources here --> | ||
|
||
This diagram illustrates what will be created by this example. | ||
|
||
<!-- insert diagram here --> | ||
|
||
## How to declare a DRG | ||
|
||
<!-- update provisioning info --> | ||
|
||
## Prerequisites | ||
|
||
You will need to collect the following information before you start: | ||
|
||
1. your OCI provider authentication values | ||
2. a compartment OCID in which the present configuration will be created | ||
|
||
For detailed instructions, see [docs/prerequisites] | ||
|
||
## Using this example with Terraform CLI | ||
|
||
Prepare one [Terraform Variable Definition file] named `terraform.tfvars` with the required authentication information. | ||
|
||
*TIP: You can rename and configure `terraform.tfvars.example` from this example's folder.* | ||
|
||
Then apply the example using the following commands: | ||
|
||
```shell | ||
> terraform init | ||
> terraform plan | ||
> terraform apply | ||
``` | ||
|
||
See [Provisioning Infrastructure with Terraform] for more details about Terraform CLI and the available subcommands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2019, 2021, Oracle Corporation and/or affiliates. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ | ||
|
||
# Version requirements | ||
|
||
terraform { | ||
required_providers { | ||
oci = { | ||
source = "hashicorp/oci" | ||
version = ">=4.41.0" | ||
} | ||
} | ||
required_version = ">= 1.0.0" | ||
} | ||
|
||
# Resources | ||
|
||
module "drg_hub" { | ||
source = "oracle-terraform-modules/vcn/oci//modules/drg" | ||
|
||
# general oci parameters | ||
compartment_id = var.compartment_id | ||
label_prefix = var.label_prefix | ||
|
||
# drg parameters | ||
drg_display_name = var.drg_display_name | ||
drg_vcn_attachments = { for k, v in module.vcn_spokes : k => { | ||
# instead of manually setting the vcn_id in a variable named var.vcn_attachments for example | ||
# this `for` expression gets the vcn_id values dynamically from the vcn module used in the same | ||
# configuration below. for example on how to setup this field manually, please see terraform.tfvars.example | ||
# in this folder. | ||
vcn_id : v.vcn_id | ||
vcn_transit_routing_rt_id : null | ||
drg_route_table_id : null | ||
} | ||
} | ||
} | ||
|
||
module "vcn_spokes" { | ||
source = "oracle-terraform-modules/vcn/oci" | ||
version = "3.1.0" | ||
for_each = var.vcn_spokes | ||
|
||
# general oci parameters | ||
compartment_id = var.compartment_id | ||
label_prefix = var.label_prefix | ||
|
||
# vcn parameters | ||
create_internet_gateway = each.value["create_internet_gateway"] # boolean: true or false | ||
lockdown_default_seclist = each.value["lockdown_default_seclist"] # boolean: true or false | ||
create_nat_gateway = each.value["create_nat_gateway"] # boolean: true or false | ||
create_service_gateway = each.value["create_service_gateway"] # boolean: true or false | ||
enable_ipv6 = each.value["enable_ipv6"] # boolean: true or false | ||
vcn_cidrs = each.value["cidrs"] # List of IPv4 CIDRs | ||
vcn_dns_label = each.value["dns_label"] # string | ||
vcn_name = each.key # string | ||
} | ||
|
||
# resource "oci_core_remote_peering_connection" "test_rpc" { | ||
# * boilerplate to start RPC support development | ||
# #Required | ||
# compartment_id = var.compartment_id | ||
# drg_id = module.drg_hub.drg_id | ||
|
||
# #Optional | ||
# # defined_tags = {"Operations.CostCenter"= "42"} | ||
# display_name = "test_rpc" | ||
# # freeform_tags = {"Department"= "Finance"} | ||
# # peer_id = oci_core_remote_peering_connection.test_remote_peering_connection2.id | ||
# # peer_region_name = var.remote_peering_connection_peer_region_name | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2019, 2021, Oracle Corporation and/or affiliates. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ | ||
|
||
# display a summary of the drg and its attachments | ||
output "module_drg_hub" { | ||
description = "drg name, OCID and vcn attachment summary" | ||
value = module.drg_hub.drg_summary | ||
} | ||
|
||
# display names and ids of a module that use for_each and shows how to use the *_all_attributes output to select a specific field | ||
output "module_vcn_spokes" { | ||
description = "vcn names and OCIDs" | ||
value = { for vcn in module.vcn_spokes : "${~vcn.vcn_all_attributes.display_name~}" => "${vcn.vcn_id~}" } | ||
# We combine here two expressions: | ||
# 1. "for" expression to loop over each key of module.vcn_spokes wrapped with {...} to produce an object | ||
# 2. "String Template directives" for interpolation and whitespace stripping: | ||
# --> ${ ... } evaluates the expression given between the markers, then inserts it into the final string https://www.terraform.io/docs/language/expressions/strings.html#interpolation | ||
# --> ~ indicates whitespace stripping before or after https://www.terraform.io/docs/language/expressions/strings.html#whitespace-stripping | ||
# | ||
# result will be an object containing "vcn.display_name" = "vcn.id" for each vcn in the vcn_spokes module | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) 2019, 2021 Oracle Corporation and/or affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl | ||
|
||
api_fingerprint = "" | ||
api_private_key_path = "" | ||
compartment_id = "" | ||
drg_display_name = "drg_hub" | ||
label_prefix = "terraform-oci" | ||
region = "" | ||
tenancy_id = "" | ||
user_id = "" | ||
vcn_spokes = { | ||
"vcn_spoke1": { | ||
"cidrs": [ | ||
"10.0.1.0/24", | ||
"10.0.2.0/24" | ||
], | ||
"create_internet_gateway": true, | ||
"create_nat_gateway": true, | ||
"create_service_gateway": true, | ||
"dns_label": "spoke1", | ||
"enable_ipv6": true, | ||
"lockdown_default_seclist": true | ||
}, | ||
"vcn_spoke2": { | ||
"cidrs": [ | ||
"10.0.3.0/24" | ||
], | ||
"create_internet_gateway": true, | ||
"create_nat_gateway": false, | ||
"create_service_gateway": true, | ||
"dns_label": "spoke2", | ||
"enable_ipv6": false, | ||
"lockdown_default_seclist": true | ||
} | ||
} | ||
vcn_attachments = { | ||
"vcn_spoke1": { | ||
vcn_id : "" | ||
vcn_transit_routing_rt_id : "" | ||
drg_route_table_id : "" | ||
}, | ||
"vcn_spoke2": { | ||
vcn_id : "" | ||
vcn_transit_routing_rt_id : "" | ||
drg_route_table_id : "" | ||
} | ||
} |
Oops, something went wrong.