Skip to content

Commit aafb97b

Browse files
Terraform Team Automationrashik-bhasin
authored andcommitted
Added - Support for GoldenGate Additional Connection Types R2.
1 parent 36fb723 commit aafb97b

10 files changed

+2206
-415
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
variable "tenancy_ocid" {}
2+
variable "user_ocid" {}
3+
variable "deployment_ocid" {}
4+
variable "fingerprint" {}
5+
variable "private_key_path" {}
6+
variable "compartment_id" {}
7+
variable "region" {}
8+
variable "subnet_id" {}
9+
variable "kms_vault_id" {}
10+
variable "kms_key_id" {}
11+
12+
variable "username" {
13+
default = "admin"
14+
}
15+
variable "password" {
16+
default = "bEStrO0nG_1"
17+
}
18+
variable "database_name" {
19+
default = "TF_PostgresqlDB"
20+
}
21+
variable "security_protocol" {
22+
default = "PLAIN"
23+
}
24+
variable "description" {
25+
default = "Created as example for TERSI-2066 Connections R2"
26+
}
27+
variable "freeform_tags" {
28+
default = { "bar-key" = "value" }
29+
}
30+
variable "private_ip" {
31+
default = "10.0.1.78"
32+
}
33+
variable "connection_type" {
34+
default = "POSTGRESQL"
35+
}
36+
variable "display_name" {
37+
default = "Postgresql_TerraformTest"
38+
}
39+
variable "technology_type" {
40+
default = "POSTGRESQL_SERVER"
41+
}
42+
variable "host"{
43+
default = "10.0.0.129"
44+
}
45+
variable "port" {
46+
default = "14"
47+
}
48+
provider "oci" {
49+
tenancy_ocid = var.tenancy_ocid
50+
user_ocid = var.user_ocid
51+
fingerprint = var.fingerprint
52+
private_key_path = var.private_key_path
53+
region = var.region
54+
}
55+
resource "oci_golden_gate_connection" "test_connection"{
56+
#Required
57+
compartment_id = var.compartment_id
58+
connection_type = var.connection_type
59+
display_name = var.display_name
60+
61+
#Required for Postgresql connection_type
62+
technology_type = var.technology_type
63+
host = var.host
64+
port = var.port
65+
username = var.username
66+
password = var.password
67+
database_name = var.database_name
68+
security_protocol = var.security_protocol
69+
70+
#Optional
71+
description = var.description
72+
freeform_tags = var.freeform_tags
73+
subnet_id = var.subnet_id
74+
vault_id = var.kms_vault_id
75+
key_id = var.kms_key_id
76+
77+
#Optional for Postgresql connection_type
78+
private_ip = var.private_ip
79+
}

internal/integrationtest/golden_gate_connection_test.go

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,41 @@ var (
7171
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.test_subnet_id}`},
7272
"vault_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.vault_id}`},
7373
}
74+
75+
PostgresqlConnectionRepresentation = map[string]interface{}{
76+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
77+
"connection_type": acctest.Representation{RepType: acctest.Required, Create: `POSTGRESQL`},
78+
"display_name": acctest.Representation{RepType: acctest.Required, Create: `Postgresql_TFtest`, Update: `Postgresql_TFtest2`},
79+
"database_name": acctest.Representation{RepType: acctest.Required, Create: `TF_PostgresqlDB`},
80+
"technology_type": acctest.Representation{RepType: acctest.Required, Create: `POSTGRESQL_SERVER`},
81+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
82+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"bar-key": "value"}},
83+
"key_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.kms_key_id}`},
84+
"host": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.127`, Update: `10.0.0.128`},
85+
"port": acctest.Representation{RepType: acctest.Required, Create: `12`, Update: `13`},
86+
"private_ip": acctest.Representation{RepType: acctest.Optional, Create: `10.0.1.78`},
87+
"password": acctest.Representation{RepType: acctest.Required, Create: `bEStrO0nG_1`},
88+
"security_protocol": acctest.Representation{RepType: acctest.Required, Create: `PLAIN`},
89+
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.test_subnet_id}`},
90+
"vault_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.vault_id}`},
91+
"username": acctest.Representation{RepType: acctest.Required, Create: `admin`},
92+
}
93+
94+
AzureSynapseConnectionRepresentation = map[string]interface{}{
95+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
96+
"connection_type": acctest.Representation{RepType: acctest.Required, Create: `AZURE_SYNAPSE_ANALYTICS`},
97+
"display_name": acctest.Representation{RepType: acctest.Required, Create: `displayName`, Update: `displayName2`},
98+
"technology_type": acctest.Representation{RepType: acctest.Required, Create: `AZURE_SYNAPSE_ANALYTICS`},
99+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
100+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"bar-key": "value"}},
101+
"key_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.kms_key_id}`},
102+
"password": acctest.Representation{RepType: acctest.Required, Create: `bEStrO0nG_1`},
103+
"private_ip": acctest.Representation{RepType: acctest.Optional, Create: `10.0.1.78`},
104+
"connection_string": acctest.Representation{RepType: acctest.Required, Create: `jdbc:sqlserver://127.0.0.1:1433`},
105+
"username": acctest.Representation{RepType: acctest.Required, Create: `admin`},
106+
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.test_subnet_id}`},
107+
"vault_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.vault_id}`},
108+
}
74109
)
75110

76111
// issue-routing-tag: golden_gate/default
@@ -112,7 +147,7 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
112147
acctest.ResourceTest(t, testAccCheckGoldenGateConnectionDestroy, []resource.TestStep{
113148
// verify Create
114149
{
115-
Config: config + compartmentIdVariableStr + testDeploymentIdVariableStr +
150+
Config: config + compartmentIdVariableStr + testDeploymentIdVariableStr + testSubnetIdVariableStr + testVaultIdVariableStr + testKeyIdVariableStr +
116151
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Required, acctest.Create,
117152
acctest.RepresentationCopyWithNewProperties(GoldenGateConnectionRepresentation, map[string]interface{}{
118153
"deployment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.test_deployment_id}`},
@@ -137,6 +172,92 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
137172
{
138173
Config: config + compartmentIdVariableStr,
139174
},
175+
// verify Create - Postgresql
176+
{
177+
Config: config + compartmentIdVariableStr + testSubnetIdVariableStr + testVaultIdVariableStr + testKeyIdVariableStr +
178+
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Required, acctest.Create, PostgresqlConnectionRepresentation),
179+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
180+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
181+
resource.TestCheckResourceAttr(resourceName, "connection_type", "POSTGRESQL"),
182+
resource.TestCheckResourceAttr(resourceName, "database_name", "TF_PostgresqlDB"),
183+
resource.TestCheckResourceAttr(resourceName, "display_name", "Postgresql_TFtest"),
184+
resource.TestCheckResourceAttr(resourceName, "host", "10.0.0.127"),
185+
resource.TestCheckResourceAttr(resourceName, "password", "bEStrO0nG_1"),
186+
resource.TestCheckResourceAttr(resourceName, "port", "12"),
187+
resource.TestCheckResourceAttr(resourceName, "username", "admin"),
188+
resource.TestCheckResourceAttrSet(resourceName, "security_protocol"),
189+
resource.TestCheckResourceAttrSet(resourceName, "state"),
190+
resource.TestCheckResourceAttr(resourceName, "technology_type", "POSTGRESQL_SERVER"),
191+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
192+
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
193+
194+
func(s *terraform.State) (err error) {
195+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
196+
return err
197+
},
198+
),
199+
},
200+
// verify Create with optionals - Postgresql
201+
{
202+
Config: config + compartmentIdVariableStr + testSubnetIdVariableStr + testVaultIdVariableStr + testKeyIdVariableStr +
203+
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Optional, acctest.Create, PostgresqlConnectionRepresentation),
204+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
205+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
206+
resource.TestCheckResourceAttr(resourceName, "connection_type", "POSTGRESQL"),
207+
resource.TestCheckResourceAttr(resourceName, "database_name", "TF_PostgresqlDB"),
208+
resource.TestCheckResourceAttr(resourceName, "description", "description"),
209+
resource.TestCheckResourceAttr(resourceName, "display_name", "Postgresql_TFtest"),
210+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
211+
resource.TestCheckResourceAttrSet(resourceName, "key_id"),
212+
resource.TestCheckResourceAttr(resourceName, "host", "10.0.0.127"),
213+
resource.TestCheckResourceAttr(resourceName, "password", "bEStrO0nG_1"),
214+
resource.TestCheckResourceAttrSet(resourceName, "private_ip"),
215+
resource.TestCheckResourceAttr(resourceName, "port", "12"),
216+
resource.TestCheckResourceAttrSet(resourceName, "security_protocol"),
217+
resource.TestCheckResourceAttrSet(resourceName, "state"),
218+
resource.TestCheckResourceAttr(resourceName, "subnet_id", testSubnetId),
219+
resource.TestCheckResourceAttr(resourceName, "technology_type", "POSTGRESQL_SERVER"),
220+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
221+
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
222+
resource.TestCheckResourceAttr(resourceName, "username", "admin"),
223+
resource.TestCheckResourceAttrSet(resourceName, "vault_id"),
224+
225+
func(s *terraform.State) (err error) {
226+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
227+
return err
228+
},
229+
),
230+
},
231+
// delete before next Create
232+
{
233+
Config: config + compartmentIdVariableStr,
234+
},
235+
// verify Create - AzureSynapse
236+
{
237+
Config: config + compartmentIdVariableStr + testSubnetIdVariableStr + testVaultIdVariableStr + testKeyIdVariableStr +
238+
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Required, acctest.Create, AzureSynapseConnectionRepresentation),
239+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
240+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
241+
resource.TestCheckResourceAttr(resourceName, "connection_string", "jdbc:sqlserver://127.0.0.1:1433"),
242+
resource.TestCheckResourceAttr(resourceName, "connection_type", "AZURE_SYNAPSE_ANALYTICS"),
243+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
244+
resource.TestCheckResourceAttr(resourceName, "password", "bEStrO0nG_1"),
245+
resource.TestCheckResourceAttr(resourceName, "username", "admin"),
246+
resource.TestCheckResourceAttrSet(resourceName, "state"),
247+
resource.TestCheckResourceAttr(resourceName, "technology_type", "AZURE_SYNAPSE_ANALYTICS"),
248+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
249+
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
250+
251+
func(s *terraform.State) (err error) {
252+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
253+
return err
254+
},
255+
),
256+
},
257+
// delete before next Create
258+
{
259+
Config: config + compartmentIdVariableStr,
260+
},
140261
// verify Create with optionals
141262
{
142263
Config: config + compartmentIdVariableStr + testVaultIdVariableStr + testSubnetIdVariableStr + testKeyIdVariableStr + testDeploymentIdVariableStr +
@@ -167,7 +288,6 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
167288
},
168289
),
169290
},
170-
171291
// verify Update to the compartment (the compartment will be switched back in the next step)
172292
{
173293
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + testSubnetIdVariableStr + testVaultIdVariableStr + testKeyIdVariableStr + testDeploymentIdVariableStr +
@@ -216,7 +336,6 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
216336
resource.TestCheckResourceAttrSet(resourceName, "id"),
217337
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
218338
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
219-
220339
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
221340
resource.TestCheckResourceAttr(resourceName, "connection_type", "GOLDENGATE"),
222341
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
@@ -291,13 +410,17 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
291410
ImportState: true,
292411
ImportStateVerify: true,
293412
ImportStateVerifyIgnore: []string{
413+
"account_key",
414+
"client_secret",
294415
"consumer_properties",
295416
"key_store",
296417
"key_store_password",
297418
"password",
298419
"private_key_file",
420+
"private_key_passphrase",
299421
"producer_properties",
300422
"public_key_fingerprint",
423+
"sas_token",
301424
"ssl_ca",
302425
"ssl_cert",
303426
"ssl_crl",

internal/integrationtest/golden_gate_deployment_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
8787
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${var.test_subnet_id}`},
8888
"license_model": acctest.Representation{RepType: acctest.Required, Create: `LICENSE_INCLUDED`},
8989
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
90-
"fqdn": acctest.Representation{RepType: acctest.Optional, Create: `fqdn1.ggs.com`},
90+
"fqdn": acctest.Representation{RepType: acctest.Required, Create: `fqdn1.ggs.com`},
9191
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
9292
"is_public": acctest.Representation{RepType: acctest.Optional, Create: `false`},
9393
"ogg_data": acctest.RepresentationGroup{RepType: acctest.Required, Group: goldenGateDeploymentOggDataRepresentation},
@@ -243,12 +243,14 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
243243
},
244244
// verify datasource
245245
{
246-
Config: config + DeploymentResourceConfig +
246+
Config: config + DeploymentResourceConfig + testDeploymentIdVariableStr +
247247
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_deployment", "test_deployment", acctest.Required, acctest.Create, goldenGateDeploymentRepresentation) +
248-
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Required, acctest.Create, GoldenGateConnectionRepresentation) +
248+
acctest.GenerateResourceFromRepresentationMap("oci_golden_gate_connection", "test_connection", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(GoldenGateConnectionRepresentation, map[string]interface{}{
249+
"host": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.127`, Update: `10.0.0.128`},
250+
"port": acctest.Representation{RepType: acctest.Required, Create: `12`, Update: `13`},
251+
})) +
249252
acctest.GenerateDataSourceFromRepresentationMap("oci_golden_gate_deployments", "depl_test_ggs_deployments", acctest.Required, acctest.Update, GoldenGateGoldenGateDeploymentDataSourceRepresentation),
250253
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
251-
//Conflict??
252254
resource.TestCheckResourceAttrSet(datasourceName, "assignable_connection_id"),
253255
resource.TestCheckResourceAttrSet(datasourceName, "assigned_connection_id"),
254256
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
@@ -259,13 +261,13 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
259261
resource.TestCheckResourceAttr(datasourceName, "supported_connection_type", "GOLDENGATE"),
260262

261263
resource.TestCheckResourceAttr(datasourceName, "deployment_collection.#", "1"),
262-
//resource.TestCheckResourceAttr(datasourceName, "deployment_collection.0.items.#", "1"),
264+
resource.TestCheckResourceAttr(datasourceName, "deployment_collection.0.items.#", "0"),
263265
),
264266
},
265267

266268
// verify singular datasource
267269
{
268-
Config: config + DeploymentResourceConfig +
270+
Config: config + DeploymentResourceConfig + testDeploymentIdVariableStr +
269271
acctest.GenerateDataSourceFromRepresentationMap("oci_golden_gate_deployment", "depl_test_ggs_deployment", acctest.Required, acctest.Create, goldenGateDeploymentSingularDataSourceRepresentation),
270272
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
271273
resource.TestCheckResourceAttrSet(singularDatasourceName, "deployment_id"),

0 commit comments

Comments
 (0)