Skip to content

Commit 1ddc7e6

Browse files
Kartiki BhatMaxrovr
authored andcommitted
Bug Fix - add support for tunnel configurations in create private ipsec over fastconnect
1 parent d2659f5 commit 1ddc7e6

File tree

6 files changed

+993
-16
lines changed

6 files changed

+993
-16
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
resource "oci_core_cpe" "test_cpe_ipsec_over_fc" {
5+
compartment_id = var.compartment_ocid
6+
display_name = "test_cpe_ipsec_over_fc"
7+
ip_address = "10.1.6.7"
8+
cpe_device_shape_id = data.oci_core_cpe_device_shape.test_cpe_device_shape.id
9+
is_private = true
10+
}
11+
12+
resource "oci_core_drg" "test_drg_ipsec_over_fc" {
13+
compartment_id = var.compartment_ocid
14+
display_name = "test_drg_ipsec_over_fc"
15+
}
16+
17+
resource "oci_core_drg_route_table" "test_drg_ipsec_over_fc_route_table" {
18+
drg_id = oci_core_drg.test_drg_ipsec_over_fc.id
19+
display_name = "DrgRtForIpsecOverFC"
20+
}
21+
22+
data "oci_core_cross_connect_locations" "cross_connect_locations" {
23+
#Required
24+
compartment_id = var.compartment_ocid
25+
}
26+
27+
data "oci_core_cross_connect_port_speed_shapes" "cross_connect_port_speed_shapes" {
28+
#Required
29+
compartment_id = var.compartment_ocid
30+
}
31+
32+
resource "oci_core_cross_connect" "test_ipsec_over_fc_cross_connect" {
33+
compartment_id = var.compartment_ocid
34+
location_name = data.oci_core_cross_connect_locations.cross_connect_locations.cross_connect_locations[0].name
35+
port_speed_shape_name = data.oci_core_cross_connect_port_speed_shapes.cross_connect_port_speed_shapes.cross_connect_port_speed_shapes[0].name
36+
display_name = "testIpsecOverFCCrossConnect"
37+
#Set Cross Connect to Active to provision (required to provision virtual circuits).
38+
#You activate it after the physical cabling is complete, and you've confirmed the cross-connect's light levels are good and your side of the interface is up
39+
is_active = true
40+
}
41+
42+
resource "oci_core_virtual_circuit" "test_ipsec_over_fc_virtual_circuit" {
43+
compartment_id = var.compartment_ocid
44+
type = "PRIVATE"
45+
bandwidth_shape_name = "100 Mbps"
46+
cross_connect_mappings {
47+
cross_connect_or_cross_connect_group_id = oci_core_cross_connect.test_ipsec_over_fc_cross_connect.id
48+
vlan = 101
49+
oracle_bgp_peering_ip = "10.0.1.21/30"
50+
customer_bgp_peering_ip = "10.0.1.22/30"
51+
}
52+
customer_asn = "64513"
53+
display_name = "testIpsecOverFCVirtualCircuit"
54+
gateway_id = oci_core_drg.test_drg_ipsec_over_fc.id
55+
}
56+
57+
resource "oci_core_ipsec" "test_ipsec_over_fc_connection" {
58+
#Required
59+
compartment_id = var.compartment_ocid
60+
cpe_id = oci_core_cpe.test_cpe_ipsec_over_fc.id
61+
drg_id = oci_core_drg.test_drg_ipsec_over_fc.id
62+
static_routes = ["10.0.0.0/16"]
63+
tunnel_configuration {
64+
oracle_tunnel_ip = "10.1.5.5"
65+
associated_virtual_circuits = [oci_core_virtual_circuit.test_ipsec_over_fc_virtual_circuit.id]
66+
drg_route_table_id = oci_core_drg_route_table.test_drg_ipsec_over_fc_route_table.id
67+
}
68+
tunnel_configuration {
69+
oracle_tunnel_ip = "10.1.7.7"
70+
associated_virtual_circuits = [oci_core_virtual_circuit.test_ipsec_over_fc_virtual_circuit.id]
71+
drg_route_table_id = oci_core_drg_route_table.test_drg_ipsec_over_fc_route_table.id
72+
}
73+
74+
#Optional
75+
cpe_local_identifier = "10.1.6.7"
76+
cpe_local_identifier_type = "IP_ADDRESS"
77+
defined_tags = {
78+
"${oci_identity_tag_namespace.tag_namespace1_fc.name}.${oci_identity_tag.tag1_fc.name}" = "value"
79+
}
80+
display_name = "MyIPSecConnectionOverFC"
81+
82+
freeform_tags = {
83+
"Department" = "Finance"
84+
}
85+
}
86+
87+
data "oci_core_ipsec_connections" "test_ip_sec_over_fc_connections" {
88+
#Required
89+
compartment_id = var.compartment_ocid
90+
91+
#Optional
92+
cpe_id = oci_core_cpe.test_cpe_ipsec_over_fc.id
93+
drg_id = oci_core_drg.test_drg_ipsec_over_fc.id
94+
}
95+
96+
data "oci_core_ipsec_connection_tunnels" "test_ip_sec_connection_tunnels_over_fc" {
97+
ipsec_id = oci_core_ipsec.test_ipsec_over_fc_connection.id
98+
}
99+
100+
data "oci_core_ipsec_connection_tunnel" "test_ipsec_connection_tunnel_over_fc" {
101+
ipsec_id = oci_core_ipsec.test_ipsec_over_fc_connection.id
102+
tunnel_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels_over_fc.ip_sec_connection_tunnels[0].id
103+
}
104+
105+
resource "oci_core_ipsec_connection_tunnel_management" "test_ipsec_connection_tunnel_management_over_fc" {
106+
ipsec_id = oci_core_ipsec.test_ipsec_over_fc_connection.id
107+
tunnel_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels_over_fc.ip_sec_connection_tunnels[0].id
108+
109+
#Optional
110+
bgp_session_info {
111+
customer_bgp_asn = "1587232876"
112+
customer_interface_ip = "10.0.0.16/31"
113+
oracle_interface_ip = "10.0.0.17/31"
114+
customer_interface_ipv6 = "2002:db2::6/64"
115+
oracle_interface_ipv6 = "2002:db2::7/64"
116+
}
117+
118+
display_name = "MyIPSecConnectionOverFCTunnelMgmt"
119+
routing = "BGP"
120+
shared_secret = "sharedSecret"
121+
ike_version = "V1"
122+
}
123+
124+
resource "oci_core_ipsec_connection_tunnel_management" "test_ipsec_connection_second_tunnel_management_over_fc" {
125+
ipsec_id = oci_core_ipsec.test_ipsec_over_fc_connection.id
126+
tunnel_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels_over_fc.ip_sec_connection_tunnels[1].id
127+
128+
#Optional
129+
display_name = "MyIPSecConnectionOverFC-Tunnel2"
130+
routing = "POLICY"
131+
shared_secret = "sharedSecret"
132+
ike_version = "V1"
133+
134+
nat_translation_enabled = "ENABLED"
135+
oracle_can_initiate = "RESPONDER_ONLY"
136+
137+
encryption_domain_config {
138+
cpe_traffic_selector = ["10.0.0.16/31", "11.0.0.16/31"]
139+
oracle_traffic_selector = ["12.0.0.16/31"]
140+
}
141+
142+
phase_one_details {
143+
is_custom_phase_one_config = false
144+
lifetime = 28600
145+
}
146+
147+
phase_two_details{
148+
dh_group = "GROUP20"
149+
is_custom_phase_two_config = false
150+
is_pfs_enabled = true
151+
lifetime = 3602
152+
}
153+
}
154+
155+
data "oci_core_ipsec_connection_tunnel_routes" "test_ipsec_connection_tunnel_routes_over_fc" {
156+
#Required
157+
ipsec_id = oci_core_ipsec.test_ipsec_over_fc_connection.id
158+
tunnel_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels_over_fc.ip_sec_connection_tunnels.0.id
159+
160+
#Optional
161+
advertiser = var.ipsec_connection_tunnel_route_advertiser
162+
}
163+
164+
resource "oci_identity_tag_namespace" "tag_namespace1_fc" {
165+
#Required
166+
compartment_id = var.tenancy_ocid
167+
description = "Just a test"
168+
name = "testexamples-tag-namespace"
169+
}
170+
171+
resource "oci_identity_tag" "tag1_fc" {
172+
#Required
173+
description = "tf example tag"
174+
name = "tf-example-tag"
175+
tag_namespace_id = oci_identity_tag_namespace.tag_namespace1_fc.id
176+
}
177+
178+
resource "oci_identity_tag" "tag2_fc" {
179+
#Required
180+
description = "tf example tag 2"
181+
name = "tf-example-tag-2"
182+
tag_namespace_id = oci_identity_tag_namespace.tag_namespace1_fc.id
183+
}
184+

internal/integrationtest/core_ipsec_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestCoreIpSecConnectionResource_basic(t *testing.T) {
9494
resource.TestCheckResourceAttrSet(resourceName, "cpe_id"),
9595
resource.TestCheckResourceAttrSet(resourceName, "drg_id"),
9696
resource.TestCheckResourceAttr(resourceName, "static_routes.#", "1"),
97+
resource.TestCheckResourceAttr(resourceName, "tunnel_configuration.#", "0"),
9798

9899
func(s *terraform.State) (err error) {
99100
resId, err = acctest.FromInstanceState(s, resourceName, "id")

0 commit comments

Comments
 (0)