@@ -55,7 +55,6 @@ resource "oci_core_route_table" "test_route_table" {
5555 freeform_tags = "${var.route_table_freeform_tags}"
5656}
5757`
58-
5958 RouteTableResourceConfigWithServiceCidr = RouteTableResourceDependencies + `
6059resource "oci_core_route_table" "test_route_table" {
6160 #Required
@@ -68,6 +67,49 @@ resource "oci_core_route_table" "test_route_table" {
6867 destination = "${lookup(data.oci_core_services.test_services.services[0], "cidr_block")}"
6968 destination_type = "${var.route_table_route_rules_destination_type}"
7069 }
70+ route_rules {
71+ #Required
72+ destination = "${var.route_table_route_rules_destination}"
73+ network_entity_id = "${oci_core_drg.test_drg.id}"
74+ }
75+ vcn_id = "${oci_core_vcn.test_vcn.id}"
76+
77+ #Optional
78+ defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.route_table_defined_tags_value}")}"
79+ display_name = "${var.route_table_display_name}"
80+ freeform_tags = "${var.route_table_freeform_tags}"
81+ }
82+
83+ resource "oci_core_service_gateway" "test_service_gateway" {
84+ #Required
85+ compartment_id = "${var.compartment_id}"
86+ services {
87+ service_id = "${lookup(data.oci_core_services.test_services.services[0], "id")}"
88+ }
89+ vcn_id = "${oci_core_vcn.test_vcn.id}"
90+ }
91+
92+ data "oci_core_services" "test_services" {
93+ }
94+ `
95+ RouteTableResourceConfigWithServiceCidrAddingCidrBlock = RouteTableResourceDependencies + `
96+ resource "oci_core_route_table" "test_route_table" {
97+ #Required
98+ compartment_id = "${var.compartment_id}"
99+ route_rules {
100+ #Required
101+ network_entity_id = "${oci_core_service_gateway.test_service_gateway.id}"
102+
103+ #Optional
104+ cidr_block = "${lookup(data.oci_core_services.test_services.services[0], "cidr_block")}"
105+ destination = "${lookup(data.oci_core_services.test_services.services[0], "cidr_block")}"
106+ destination_type = "${var.route_table_route_rules_destination_type}"
107+ }
108+ route_rules {
109+ #Required
110+ destination = "${var.route_table_route_rules_destination}"
111+ network_entity_id = "${oci_core_drg.test_drg.id}"
112+ }
71113 vcn_id = "${oci_core_vcn.test_vcn.id}"
72114
73115 #Optional
@@ -240,8 +282,53 @@ variable "route_table_state" { default = "AVAILABLE" }
240282 Check : resource .ComposeAggregateTestCheckFunc (
241283 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
242284 resource .TestCheckResourceAttrSet (resourceName , "id" ),
243- resource .TestCheckResourceAttr (resourceName , "route_rules.#" , "1" ),
285+ resource .TestCheckResourceAttr (resourceName , "route_rules.#" , "2" ),
286+ CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "SERVICE_CIDR_BLOCK" }, []string {"network_entity_id" , "destination" }),
287+ CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "CIDR_BLOCK" , "destination" : "0.0.0.0/0" }, []string {"network_entity_id" }),
288+ resource .TestCheckResourceAttrSet (resourceName , "state" ),
289+ resource .TestCheckResourceAttrSet (resourceName , "vcn_id" ),
290+ ),
291+ },
292+ // verify update after having a destination_type rule
293+ {
294+ Config : config + `
295+ variable "route_table_defined_tags_value" { default = "value" }
296+ variable "route_table_display_name" { default = "MyRouteTable" }
297+ variable "route_table_freeform_tags" { default = {"Department"= "Finance"} }
298+ variable "route_table_route_rules_cidr_block" { default = "10.0.0.0/8" }
299+ variable "route_table_route_rules_destination" { default = "0.0.0.0/1" }
300+ variable "route_table_route_rules_destination_type" { default = "SERVICE_CIDR_BLOCK" }
301+ variable "route_table_state" { default = "AVAILABLE" }
302+
303+ ` + compartmentIdVariableStr + RouteTableResourceConfigWithServiceCidr ,
304+ Check : resource .ComposeAggregateTestCheckFunc (
305+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
306+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
307+ resource .TestCheckResourceAttr (resourceName , "route_rules.#" , "2" ),
308+ CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "SERVICE_CIDR_BLOCK" }, []string {"network_entity_id" , "destination" }),
309+ CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "CIDR_BLOCK" , "destination" : "0.0.0.0/1" }, []string {"network_entity_id" }),
310+ resource .TestCheckResourceAttrSet (resourceName , "state" ),
311+ resource .TestCheckResourceAttrSet (resourceName , "vcn_id" ),
312+ ),
313+ },
314+ // verify adding cidr_block to a rule that has destination already
315+ {
316+ Config : config + `
317+ variable "route_table_defined_tags_value" { default = "value" }
318+ variable "route_table_display_name" { default = "MyRouteTable" }
319+ variable "route_table_freeform_tags" { default = {"Department"= "Finance"} }
320+ variable "route_table_route_rules_cidr_block" { default = "10.0.0.0/8" }
321+ variable "route_table_route_rules_destination" { default = "0.0.0.0/1" }
322+ variable "route_table_route_rules_destination_type" { default = "SERVICE_CIDR_BLOCK" }
323+ variable "route_table_state" { default = "AVAILABLE" }
324+
325+ ` + compartmentIdVariableStr + RouteTableResourceConfigWithServiceCidrAddingCidrBlock ,
326+ Check : resource .ComposeAggregateTestCheckFunc (
327+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
328+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
329+ resource .TestCheckResourceAttr (resourceName , "route_rules.#" , "2" ),
244330 CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "SERVICE_CIDR_BLOCK" }, []string {"network_entity_id" , "destination" }),
331+ CheckResourceSetContainsElementWithProperties (resourceName , "route_rules" , map [string ]string {"destination_type" : "CIDR_BLOCK" , "destination" : "0.0.0.0/1" }, []string {"network_entity_id" }),
245332 resource .TestCheckResourceAttrSet (resourceName , "state" ),
246333 resource .TestCheckResourceAttrSet (resourceName , "vcn_id" ),
247334 ),
0 commit comments