Skip to content

Commit 98927ec

Browse files
Borys Shchipanskyigovindrao55
authored andcommitted
Support UpdateDrgAttachment of types Virtual_Circuit, RPC and IPSec
1 parent ec90cf7 commit 98927ec

11 files changed

+890
-76
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Support for Bastion Service
88
- Support charge for Container Images and Generic Artifacts
99
- Support for Generic Artifacts Service
10+
- Support Update `DrgAttachment` of types `Virtual_Circuit`, `RPC` and `IPSec`
1011

1112
## 4.27.0 (May 19, 2021)
1213

Lines changed: 43 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,71 @@
11
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
22
// Licensed under the Mozilla Public License v2.0
33

4-
variable "tenancy_ocid" {
5-
}
6-
7-
variable "user_ocid" {
8-
}
9-
10-
variable "fingerprint" {
11-
}
12-
13-
variable "private_key_path" {
14-
}
15-
16-
variable "region" {
17-
}
184

19-
variable "compartment_ocid" {
20-
}
21-
22-
provider "oci" {
23-
tenancy_ocid = var.tenancy_ocid
24-
user_ocid = var.user_ocid
25-
fingerprint = var.fingerprint
26-
private_key_path = var.private_key_path
27-
region = var.region
28-
}
29-
30-
variable "instance_image_ocid" {
31-
type = map(string)
32-
33-
default = {
34-
# See https://docs.us-phoenix-1.oraclecloud.com/images/
35-
# Oracle-provided image "Oracle-Linux-7.5-2018.10.16-0"
36-
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaaoqj42sokaoh42l76wsyhn3k2beuntrh5maj3gmgmzeyr55zzrwwa"
37-
us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaageeenzyuxgia726xur4ztaoxbxyjlxogdhreu3ngfj2gji3bayda"
38-
eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaaitzn6tdyjer7jl34h2ujz74jwy5nkbukbh55ekp6oyzwrtfa4zma"
39-
uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaa32voyikkkzfxyo4xbdmadc2dmvorfxxgdhpnk6dw64fa3l4jh7wa"
40-
}
41-
}
425

436
resource "oci_core_vcn" "test_vcn_a" {
44-
// required
7+
// Required
458
cidr_block = "10.0.0.0/16"
469
compartment_id = var.compartment_ocid
4710

48-
// optional
49-
display_name = "testVcnA"
11+
// Optional
12+
display_name = "MyTestVcnA"
5013
dns_label = "dnslabelA"
5114
}
5215

5316

5417
resource "oci_core_vcn" "test_vcn_b" {
55-
// required
18+
// Required
5619
cidr_block = "20.0.0.0/16"
5720
compartment_id = var.compartment_ocid
5821

59-
// optional
60-
display_name = "testVcnB"
22+
// Optional
23+
display_name = "MyTestVcnB"
6124
dns_label = "dnslabelB"
6225
}
6326

6427

65-
resource "oci_core_drg" "test_drg" {
66-
// required
28+
resource "oci_core_drg" "test_vcn_drg" {
29+
// Required
6730
compartment_id = var.compartment_ocid
6831

69-
// optional
70-
display_name = "testDrg"
32+
// Optional
33+
display_name = "MyTestVcnDrg"
7134
}
7235

73-
resource "oci_core_drg_route_distribution" "test_drg_route_distribution" {
74-
// required
75-
drg_id = oci_core_drg.test_drg.id
36+
resource "oci_core_drg_route_distribution" "test_vcn_drg_route_distribution" {
37+
// Required
38+
drg_id = oci_core_drg.test_vcn_drg.id
7639
distribution_type = "IMPORT"
7740

7841
// optional
79-
display_name = "testDrgRouteDistribution"
42+
display_name = "MyTestVcnDrgRouteDistribution"
8043

8144
}
8245

83-
resource "oci_core_drg_attachment" "test_drg_attachment_a" {
84-
// required
85-
drg_id = oci_core_drg.test_drg.id
46+
resource "oci_core_drg_attachment" "test_vcn_drg_attachment_a" {
47+
// Required
48+
drg_id = oci_core_drg.test_vcn_drg.id
8649
vcn_id = oci_core_vcn.test_vcn_a.id
8750

51+
// Optional
52+
drg_route_table_id = oci_core_drg_route_table.test_vcn_drg_route_table.id
53+
8854
}
8955

90-
resource "oci_core_drg_attachment" "test_drg_attachment_b" {
91-
// required
92-
drg_id = oci_core_drg.test_drg.id
56+
resource "oci_core_drg_attachment" "test_vcn_drg_attachment_b" {
57+
// Required
58+
drg_id = oci_core_drg.test_vcn_drg.id
9359
vcn_id = oci_core_vcn.test_vcn_b.id
9460

61+
// Optional
62+
drg_route_table_id = oci_core_drg_route_table.test_vcn_drg_route_table.id
63+
9564
}
9665

97-
resource "oci_core_drg_route_distribution_statement" "test_drg_route_distribution_statements" {
98-
// required
99-
drg_route_distribution_id = oci_core_drg_route_distribution.test_drg_route_distribution.id
66+
resource "oci_core_drg_route_distribution_statement" "test_vcn_drg_route_distribution_statements" {
67+
// Required
68+
drg_route_distribution_id = oci_core_drg_route_distribution.test_vcn_drg_route_distribution.id
10069
action = "ACCEPT"
10170

10271
match_criteria {
@@ -109,19 +78,24 @@ resource "oci_core_drg_route_distribution_statement" "test_drg_route_distributio
10978

11079
}
11180

112-
data "oci_core_drg_route_distribution" "test_drg_route_distribution_data" {
113-
// required
114-
drg_route_distribution_id = oci_core_drg_route_distribution.test_drg_route_distribution.id
81+
data "oci_core_drg_route_distribution" "test_vcn_drg_route_distribution_data" {
82+
// Required
83+
drg_route_distribution_id = oci_core_drg_route_distribution.test_vcn_drg_route_distribution.id
11584
}
11685

117-
resource "oci_core_drg_route_table" "test_drg_route_table" {
118-
drg_id = oci_core_drg.test_drg.id
86+
resource "oci_core_drg_route_table" "test_vcn_drg_route_table" {
87+
drg_id = oci_core_drg.test_vcn_drg.id
88+
89+
// Optional
90+
import_drg_route_distribution_id = oci_core_drg_route_distribution.test_vcn_drg_route_distribution.id
91+
display_name = "MyTestVcnDrgRouteTable"
11992
}
12093

121-
resource "oci_core_drg_route_table_route_rule" "test_drg_route_table_route_rule" {
122-
#Required
123-
drg_route_table_id = oci_core_drg_route_table.test_drg_route_table.id
94+
resource "oci_core_drg_route_table_route_rule" "test_vcn_drg_route_table_route_rule" {
95+
// Required
96+
drg_route_table_id = oci_core_drg_route_table.test_vcn_drg_route_table.id
12497
destination = "10.0.0.0/8"
12598
destination_type = "CIDR_BLOCK"
126-
next_hop_drg_attachment_id = oci_core_drg_attachment.test_drg_attachment_a.id
99+
next_hop_drg_attachment_id = oci_core_drg_attachment.test_vcn_drg_attachment_a.id
127100
}
101+
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
resource "oci_core_drg" "test_drg" {
5+
// required
6+
compartment_id = var.compartment_ocid
7+
8+
// optional
9+
display_name = "MyTestDrg"
10+
}
11+
12+
resource "oci_core_drg_route_distribution" "test_drg_route_distribution" {
13+
// Required
14+
drg_id = oci_core_drg.test_drg.id
15+
distribution_type = "IMPORT"
16+
17+
// Optional
18+
display_name = "MyTestDrgRouteDistribution"
19+
}
20+
21+
resource "oci_core_drg_route_table" "test_drg_route_table" {
22+
// Required
23+
drg_id = oci_core_drg.test_drg.id
24+
25+
// Optional
26+
import_drg_route_distribution_id = oci_core_drg_route_distribution.test_drg_route_distribution.id
27+
display_name = "MyTestDrgRouteTable"
28+
}
29+
30+
// RPC
31+
resource "oci_core_remote_peering_connection" "test_rpc" {
32+
33+
compartment_id = var.compartment_ocid
34+
drg_id = oci_core_drg.test_drg.id
35+
display_name = "MyTestRemotePeeringConnection"
36+
}
37+
38+
39+
// IPSec Start
40+
41+
resource "oci_core_ipsec" "test_ip_sec_connection" {
42+
// Required
43+
compartment_id = var.compartment_ocid
44+
cpe_id = oci_core_cpe.test_cpe.id
45+
drg_id = oci_core_drg.test_drg.id
46+
static_routes = [
47+
"10.0.0.0/16"]
48+
49+
// Optional
50+
cpe_local_identifier = "189.44.2.135"
51+
cpe_local_identifier_type = "IP_ADDRESS"
52+
display_name = "MyTestIPSecConnection"
53+
54+
freeform_tags = {
55+
"Department" = "Finance"
56+
}
57+
}
58+
59+
resource "oci_core_cpe" "test_cpe" {
60+
compartment_id = var.compartment_ocid
61+
display_name = "test_cpe"
62+
ip_address = "189.44.2.135"
63+
cpe_device_shape_id = data.oci_core_cpe_device_shape.test_cpe_device_shape.id
64+
}
65+
66+
data "oci_core_cpe_device_shape" "test_cpe_device_shape" {
67+
cpe_device_shape_id = data.oci_core_cpe_device_shapes.test_cpe_device_shapes.cpe_device_shapes[0].cpe_device_shape_id
68+
}
69+
70+
data "oci_core_ipsec_connection_tunnels" "test_ip_sec_connection_tunnels" {
71+
ipsec_id = oci_core_ipsec.test_ip_sec_connection.id
72+
}
73+
data "oci_core_cpe_device_shapes" "test_cpe_device_shapes" {
74+
}
75+
// IPsec end
76+
77+
78+
// Get auto generated attachment for ipsec tunnel 1
79+
resource "oci_core_drg_attachment_management" "test_drg_ipsec_attachment_tunnel_1" {
80+
// Required
81+
attachment_type = "IPSEC_TUNNEL"
82+
compartment_id = var.compartment_ocid
83+
drg_id = oci_core_drg.test_vcn_drg.id
84+
network_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels.ip_sec_connection_tunnels[0].id
85+
86+
// Optional
87+
display_name = "MyTestDrgAttachmentForTunnel1"
88+
drg_route_table_id = oci_core_drg_route_table.test_drg_route_table.id
89+
90+
}
91+
// Get auto generated attachment for ipsec tunnel 2
92+
resource "oci_core_drg_attachment_management" "test_drg_ipsec_attachment_tunnel_2" {
93+
// Required
94+
attachment_type = "IPSEC_TUNNEL"
95+
compartment_id = var.compartment_ocid
96+
drg_id = oci_core_drg.test_vcn_drg.id
97+
network_id = data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels.ip_sec_connection_tunnels[1].id
98+
99+
// Optional
100+
display_name = "MyTestDrgAttachmentForTunnel2"
101+
drg_route_table_id = oci_core_drg_route_table.test_drg_route_table.id
102+
103+
}
104+
105+
// Get auto generated attachment for rpc by rpc.id
106+
resource "oci_core_drg_attachment_management" "test_drg_rpc_attachment" {
107+
// Required
108+
attachment_type = "REMOTE_PEERING_CONNECTION"
109+
compartment_id = var.compartment_ocid
110+
network_id = oci_core_remote_peering_connection.test_rpc.id
111+
drg_id = oci_core_drg.test_vcn_drg.id
112+
113+
// Optional
114+
display_name = "MyTestDrgAttachmentForRpc"
115+
drg_route_table_id = oci_core_drg_route_table.test_drg_route_table.id
116+
117+
}
118+
//
119+
120+
// Add Static route
121+
resource "oci_core_drg_route_table_route_rule" "test_drg_rpc_route_table_route_rule" {
122+
drg_route_table_id = oci_core_drg_route_table.test_drg_route_table.id
123+
destination = "10.0.0.0/16"
124+
destination_type = "CIDR_BLOCK"
125+
next_hop_drg_attachment_id = oci_core_drg_attachment_management.test_drg_rpc_attachment.id
126+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
variable "tenancy_ocid" {
2+
}
3+
4+
variable "user_ocid" {
5+
}
6+
7+
variable "fingerprint" {
8+
}
9+
10+
variable "private_key_path" {
11+
}
12+
13+
variable "region" {
14+
}
15+
16+
variable "compartment_ocid" {
17+
}
18+
19+
provider "oci" {
20+
tenancy_ocid = var.tenancy_ocid
21+
user_ocid = var.user_ocid
22+
fingerprint = var.fingerprint
23+
private_key_path = var.private_key_path
24+
region = var.region
25+
}
26+
27+
variable "instance_image_ocid" {
28+
type = map(string)
29+
30+
default = {
31+
# See https://docs.us-phoenix-1.oraclecloud.com/images/
32+
# Oracle-provided image "Oracle-Linux-7.5-2018.10.16-0"
33+
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaaoqj42sokaoh42l76wsyhn3k2beuntrh5maj3gmgmzeyr55zzrwwa"
34+
us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaageeenzyuxgia726xur4ztaoxbxyjlxogdhreu3ngfj2gji3bayda"
35+
eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaaitzn6tdyjer7jl34h2ujz74jwy5nkbukbh55ekp6oyzwrtfa4zma"
36+
uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaa32voyikkkzfxyo4xbdmadc2dmvorfxxgdhpnk6dw64fa3l4jh7wa"
37+
}
38+
}

0 commit comments

Comments
 (0)