Skip to content

Commit

Permalink
Add module + examples mock
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Natarov authored and Vitaliy Natarov committed Jan 15, 2025
1 parent ddab2f0 commit 202ef75
Show file tree
Hide file tree
Showing 12 changed files with 1,051 additions and 20 deletions.
173 changes: 171 additions & 2 deletions oracle_cloud/examples/core_drg/README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions oracle_cloud/examples/core_drg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ provider "oci" {
module "core_drg" {
source = "../../modules/core_drg"

enable_core_drg = true
core_drg_compartment_id = ""
core_drg_display_name = ""

tags = {}
}
37 changes: 35 additions & 2 deletions oracle_cloud/modules/core_drg/drg.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
#-----------------------------------------------------------
# core_drg
# core drg
#-----------------------------------------------------------
resource "oci_core_drg" "core_drg" {
count = var.enable_core_drg ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg
# Required
compartment_id = var.core_drg_compartment_id

# Optional
display_name = var.core_drg_display_name != "" ? var.core_drg_display_name : "${lower(var.name)}-drg-${lower(var.environment)}"

defined_tags = merge(
{
Name = var.core_drg_display_name != "" ? var.core_drg_display_name : "${lower(var.name)}-drg-${lower(var.environment)}"
},
var.tags
)
freeform_tags = var.core_drg_freeform_tags

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_timeouts)) > 0 ? [var.core_drg_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
53 changes: 51 additions & 2 deletions oracle_cloud/modules/core_drg/drg_attachment.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
#-----------------------------------------------------------
# drg_attachment
# core drg attachment
#-----------------------------------------------------------
resource "oci_core_drg_attachment" "core_drg_attachment" {
count = var.enable_core_drg_attachment ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_attachment
# Required
drg_id = var.core_drg_attachment_drg_id != "" && !var.enable_core_drg ? var.core_drg_attachment_drg_id : (var.enable_core_drg ? element(oci_core_drg.core_drg.*.id, 0) : null)

# Optional
display_name = var.core_drg_attachment_display_name != "" ? var.core_drg_attachment_display_name : "${lower(var.name)}-drg-attachment-${lower(var.environment)}"
drg_route_table_id = var.core_drg_attachment_drg_route_table_id != "" && !var.enable_core_drg_route_table ? var.core_drg_attachment_drg_route_table_id : (var.enable_core_drg_route_table ? element(oci_core_drg_route_table.core_drg_route_table.*.id, 0) : null)

dynamic "network_details" {
iterator = network_details
for_each = var.core_drg_attachment_network_details

content {
# Required
type = lookup(network_details.value, "type", null)

# Optional
id = lookup(network_details.value, "id", null)
route_table_id = lookup(network_details.value, "route_table_id", null)
vcn_route_type = lookup(network_details.value, "vcn_route_type", null)
}
}

defined_tags = merge(
{
Name = var.core_drg_attachment_display_name != "" ? var.core_drg_attachment_display_name : "${lower(var.name)}-drg-attachment-${lower(var.environment)}"
},
var.tags
)
freeform_tags = var.core_drg_attachment_freeform_tags

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_attachment_timeouts)) > 0 ? [var.core_drg_attachment_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
22 changes: 20 additions & 2 deletions oracle_cloud/modules/core_drg/drg_attachment_management.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#-----------------------------------------------------------
# drg_attachment_management
# core drg attachment management
#-----------------------------------------------------------
resource "oci_core_drg_attachment_management" "core_drg_attachment_management" {
count = var.enable_core_drg_attachment_management ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_attachment_management
# Required
attachment_type = var.core_drg_attachment_management_attachment_type
compartment_id = var.core_drg_attachment_management_compartment_id
drg_id = var.core_drg_attachment_management_drg_id != "" && !var.enable_core_drg ? var.core_drg_attachment_management_drg_id : (var.enable_core_drg ? element(oci_core_drg.core_drg.*.id, 0) : null)

# Optional
network_id = var.core_drg_attachment_management_network_id
display_name = var.core_drg_attachment_management_display_name != "" ? var.core_drg_attachment_management_display_name : "${lower(var.name)}-drg-attachment-management-${lower(var.environment)}"
drg_route_table_id = var.core_drg_attachment_management_drg_route_table_id != "" && !var.enable_core_drg_route_table ? var.core_drg_attachment_management_drg_route_table_id : (var.enable_core_drg_route_table ? element(oci_core_drg_route_table.core_drg_route_table.*.id, 0) : null)

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
30 changes: 28 additions & 2 deletions oracle_cloud/modules/core_drg/drg_attachments_list.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#-----------------------------------------------------------
# drg_attachments_list
# core drg attachments list
#-----------------------------------------------------------
resource "oci_core_drg_attachments_list" "core_drg_attachments_list" {
count = var.enable_core_drg_attachments_list ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_attachments_list
# Required
drg_id = var.core_drg_attachments_list_drg_id && !var.enable_core_drg ? var.core_drg_attachments_list_drg_id : (var.enable_core_drg ? element(oci_core_drg.core_drg.*.id, 0) : null)

# Optional
attachment_type = var.core_drg_attachments_list_attachment_type
is_cross_tenancy = var.core_drg_attachments_list_is_cross_tenancy

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_attachments_list_timeouts)) > 0 ? [var.core_drg_attachments_list_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
38 changes: 36 additions & 2 deletions oracle_cloud/modules/core_drg/drg_route_distribution.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
#-----------------------------------------------------------
# drg_route_distribution
# core drg route distribution
#-----------------------------------------------------------
resource "oci_core_drg_route_distribution" "drg_route_distribution" {
count = var.enable_drg_route_distribution ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_route_distribution
# Required
distribution_type = var.drg_route_distribution_distribution_type
drg_id = var.drg_route_distribution_drg_id != "" && !var.enable_core_drg ? var.drg_route_distribution_drg_id : (var.enable_core_drg ? element(oci_core_drg.core_drg.*.id, 0) : null)

# Optional
display_name = var.drg_route_distribution_display_name != "" ? var.drg_route_distribution_display_name : "${lower(var.name)}-drg-route-distribution-${lower(var.environment)}"

defined_tags = merge(
{
Name = var.drg_route_distribution_display_name != "" ? var.drg_route_distribution_display_name : "${lower(var.name)}-drg-route-distribution-${lower(var.environment)}"
},
var.tags
)
freeform_tags = var.drg_route_distribution_freeform_tags

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.drg_route_distribution_timeouts)) > 0 ? [var.drg_route_distribution_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
45 changes: 43 additions & 2 deletions oracle_cloud/modules/core_drg/drg_route_distribution_statement.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
#-----------------------------------------------------------
# drg_route_distribution_statement
# core drg route distribution statement
#-----------------------------------------------------------
resource "oci_core_drg_route_distribution_statement" "core_drg_route_distribution_statement" {
count = var.enable_core_drg_route_distribution_statement ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_route_distribution_statement
# Required
drg_route_distribution_id = var.core_drg_route_distribution_statement_drg_route_distribution_id != "" && !var.enable_drg_route_distribution ? var.core_drg_route_distribution_statement_drg_route_distribution_id : (var.enable_drg_route_distribution ? element(oci_core_drg_route_distribution.core_drg_route_distribution.*.id, 0) : null)
action = var.core_drg_route_distribution_statement_action

dynamic "match_criteria" {
iterator = match_criteria
for_each = length(keys(var.core_drg_route_distribution_statement_match_criteria)) > 0 ? [var.core_drg_route_distribution_statement_match_criteria] : []

content {
# Required
match_type = lookup(match_criteria.value, "match_type", null)

# Optional
attachment_type = lookup(match_criteria.value, "attachment_type", null)
drg_attachment_id = lookup(match_criteria.value, "drg_attachment_id", (var.enable_core_drg_attachment ? element(oci_core_drg_attachment.core_drg_attachment.*.id, 0) : null))
}
}

# Optional
priority = var.core_drg_route_distribution_statement_priority

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_route_distribution_statement_timeouts)) > 0 ? [var.core_drg_route_distribution_statement_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []

}
41 changes: 39 additions & 2 deletions oracle_cloud/modules/core_drg/drg_route_table.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
#-----------------------------------------------------------
# drg_route_table
# core drg route table
#-----------------------------------------------------------
resource "oci_core_drg_route_table" "core_drg_route_table" {
count = var.enable_core_drg_route_table ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_route_table
# Required
drg_id = var.core_drg_route_table_drg_id != "" && !var.enable_core_drg ? var.core_drg_route_table_drg_id : (var.enable_core_drg ? element(oci_core_drg.core_drg.*.id, 0) : null)

# Optional
display_name = var.core_drg_route_table_display_name != "" ? var.core_drg_route_table_display_name : "${lower(var.name)}-drg-route-table-${lower(var.environment)}"
import_drg_route_distribution_id = var.core_drg_route_table_import_drg_route_distribution_id != "" && !var.enable_core_drg ? var.core_drg_route_table_import_drg_route_distribution_id : (var.enable_core_drg ? element(oci_core_drg_route_distribution.core_drg_route_distribution.*.id, 0) : null)
is_ecmp_enabled = var.core_drg_route_table_is_ecmp_enabled
remove_import_trigger = var.core_drg_route_table_remove_import_trigger

defined_tags = merge(
{
Name = var.core_drg_route_table_display_name != "" ? var.core_drg_route_table_display_name : "${lower(var.name)}-drg-route-table-${lower(var.environment)}"
},
var.tags
)
freeform_tags = var.core_drg_route_table_freeform_tags

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_route_table_timeouts)) > 0 ? [var.core_drg_route_table_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []

}
29 changes: 27 additions & 2 deletions oracle_cloud/modules/core_drg/drg_route_table_route_rule.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
#-----------------------------------------------------------
# drg_route_table_route_rule
# core drg route table route rule
#-----------------------------------------------------------
resource "oci_core_drg_route_table_route_rule" "core_drg_route_table_route_rule" {
count = var.enable_core_drg_route_table_route_rule ? 1 : 0

# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_drg_route_table_route_rule
# Required
drg_route_table_id = var.core_drg_route_table_route_rule_drg_route_table_id != "" && !var.enable_core_drg_route_table ? var.core_drg_route_table_route_rule_drg_route_table_id : (var.enable_core_drg_route_table ? element(oci_core_drg_route_table.core_drg_route_table.*.id, 0) : null)
destination = var.core_drg_route_table_route_rule_destination
destination_type = var.core_drg_route_table_route_rule_destination_type
next_hop_drg_attachment_id = var.core_drg_route_table_route_rule_next_hop_drg_attachment_id != "" && !var.enable_core_drg_attachment ? var.core_drg_route_table_route_rule_next_hop_drg_attachment_id : (var.enable_core_drg_attachment ? element(oci_core_drg_attachment.core_drg_attachment.*.id, 0) : null)

dynamic "timeouts" {
iterator = timeouts
for_each = length(keys(var.core_drg_route_table_route_rule_timeouts)) > 0 ? [var.core_drg_route_table_route_rule_timeouts] : []

content {
create = lookup(timeouts.value, "create", null)
update = lookup(timeouts.value, "update", null)
delete = lookup(timeouts.value, "delete", null)
}
}

lifecycle {
create_before_destroy = true
ignore_changes = []
}

depends_on = []
}
Loading

0 comments on commit 202ef75

Please sign in to comment.