Skip to content

Commit 5471f12

Browse files
Terraform Team AutomationMaxrovr
authored andcommitted
Added - Support for Add DB2 deployment and additional connection types (R5)
1 parent 0fe42c5 commit 5471f12

23 files changed

+680
-52
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 "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_DB2"
20+
}
21+
variable "security_protocol" {
22+
default = "PLAIN"
23+
}
24+
variable "description" {
25+
default = "Created as example for TERSI-3444 Connections R5"
26+
}
27+
variable "freeform_tags" {
28+
default = { "bar-key" = "value" }
29+
}
30+
variable "connection_type" {
31+
default = "DB2"
32+
}
33+
variable "display_name" {
34+
default = "Db2_TerraformTest"
35+
}
36+
variable "technology_type" {
37+
default = "DB2_ZOS"
38+
}
39+
variable "host"{
40+
default = "10.0.0.129"
41+
}
42+
variable "port" {
43+
default = "10000"
44+
}
45+
provider "oci" {
46+
tenancy_ocid = var.tenancy_ocid
47+
user_ocid = var.user_ocid
48+
fingerprint = var.fingerprint
49+
private_key_path = var.private_key_path
50+
region = var.region
51+
}
52+
resource "oci_golden_gate_connection" "test_connection"{
53+
#Required
54+
compartment_id = var.compartment_id
55+
connection_type = var.connection_type
56+
display_name = var.display_name
57+
58+
#Required for Postgresql connection_type
59+
technology_type = var.technology_type
60+
host = var.host
61+
port = var.port
62+
username = var.username
63+
password = var.password
64+
database_name = var.database_name
65+
security_protocol = var.security_protocol
66+
67+
#Optional
68+
description = var.description
69+
freeform_tags = var.freeform_tags
70+
subnet_id = var.subnet_id
71+
vault_id = var.vault_id
72+
key_id = var.kms_key_id
73+
}

internal/integrationtest/golden_gate_connection_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var (
8989
oci_golden_gate.ConnectionTypeAzureDataLakeStorage,
9090
oci_golden_gate.ConnectionTypeAzureSynapseAnalytics,
9191
// oci_golden_gate.ConnectionTypeCassandra, //TODO 2023. 09. 19. lmadaras: to be tested
92-
// oci_golden_gate.ConnectionTypeDb2, //TODO 2023. 09. 19. lmadaras: to be tested
92+
oci_golden_gate.ConnectionTypeDb2,
9393
oci_golden_gate.ConnectionTypeElasticsearch,
9494
oci_golden_gate.ConnectionTypeGoldengate,
9595
oci_golden_gate.ConnectionTypeGeneric,
@@ -214,18 +214,17 @@ var (
214214
// },
215215
//},
216216
//
217-
//// DB2
218-
//{connectionType: oci_golden_gate.ConnectionTypeDb2, technologyType: oci_golden_gate.TechnologyTypeDb2Zos,
219-
// representation: map[string]interface{}{
220-
// "database_name": acctest.Representation{RepType: acctest.Required, Create: `database1`, Update: `database2`},
221-
// "host": acctest.Representation{RepType: acctest.Required, Create: `whatever1.fqdn.com`, Update: `whatever2.fqdn.com`},
222-
// "port": acctest.Representation{RepType: acctest.Required, Create: `10000`, Update: `10001`},
223-
// "username": acctest.Representation{RepType: acctest.Required, Create: `admin`, Update: `new_admin`},
224-
// "password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
225-
// "security_protocol": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.Db2ConnectionSecurityProtocolPlain)},
226-
// "private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
227-
// },
228-
//},
217+
// DB2
218+
{connectionType: oci_golden_gate.ConnectionTypeDb2, technologyType: oci_golden_gate.TechnologyTypeDb2Zos,
219+
representation: map[string]interface{}{
220+
"database_name": acctest.Representation{RepType: acctest.Required, Create: `database1`, Update: `database2`},
221+
"host": acctest.Representation{RepType: acctest.Required, Create: `whatever1.fqdn.com`, Update: `whatever2.fqdn.com`},
222+
"port": acctest.Representation{RepType: acctest.Required, Create: `10000`, Update: `10001`},
223+
"username": acctest.Representation{RepType: acctest.Required, Create: `admin`, Update: `new_admin`},
224+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
225+
"security_protocol": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.Db2ConnectionSecurityProtocolPlain)},
226+
},
227+
},
229228

230229
// Elasticsearch
231230
{connectionType: oci_golden_gate.ConnectionTypeElasticsearch, technologyType: oci_golden_gate.TechnologyTypeElasticsearch,

internal/integrationtest/golden_gate_deployment_backup_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
3636
OBJECTSTORAGE_BUCKET_NAME = "objectstorage_bucket_name"
3737
OBJECTSTORAGE_NAMESPACE = "objectstorage_namespace"
3838
TEST_DEPLOYMENT_ID = "test_deployment_id"
39+
TEST_DEPLOYMENT_TYPE = "test_deployment_type"
3940
)
4041

4142
var (
@@ -46,6 +47,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
4647
testCompartmentId = utils.GetEnvSettingWithBlankDefault(COMPARTMENT_ID)
4748
compartmentIdForMove = utils.GetEnvSettingWithBlankDefault(COMPARTMENT_ID_FOR_MOVE)
4849
resId string
50+
testDeploymentType = utils.GetEnvSettingWithBlankDefault(TEST_DEPLOYMENT_TYPE)
4951
)
5052

5153
var (
@@ -112,6 +114,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
112114
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
113115
resource.TestCheckResourceAttr(resourceName, "compartment_id", testCompartmentId),
114116
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
117+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
115118
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
116119
resource.TestCheckResourceAttrSet(resourceName, "namespace"),
117120
resource.TestCheckResourceAttr(resourceName, "object", "object"),
@@ -136,7 +139,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
136139
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
137140
resource.TestCheckResourceAttr(resourceName, "compartment_id", testCompartmentId),
138141
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
139-
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
142+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
140143
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
141144
resource.TestCheckResourceAttrSet(resourceName, "id"),
142145
resource.TestCheckResourceAttrSet(resourceName, "namespace"),
@@ -167,6 +170,8 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
167170
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
168171
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdForMove),
169172
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
173+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
174+
resource.TestCheckResourceAttrSet(resourceName, "deployment_type"),
170175
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
171176
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
172177
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -192,6 +197,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
192197
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
193198
resource.TestCheckResourceAttr(resourceName, "compartment_id", testCompartmentId),
194199
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
200+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
195201
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
196202
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
197203
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -217,6 +223,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
217223
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
218224
resource.TestCheckResourceAttr(datasourceName, "compartment_id", testCompartmentId),
219225
resource.TestCheckResourceAttrSet(datasourceName, "deployment_id"),
226+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
220227
resource.TestCheckResourceAttr(datasourceName, "display_name", "demoDeploymentBackup"),
221228
resource.TestCheckResourceAttr(datasourceName, "state", "ACTIVE"),
222229

@@ -235,6 +242,7 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
235242
resource.TestCheckResourceAttrSet(singularDatasourceName, "backup_type"),
236243
resource.TestCheckResourceAttrSet(singularDatasourceName, "bucket"),
237244
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", testCompartmentId),
245+
resource.TestCheckResourceAttr(resourceName, "deployment_type", testDeploymentType),
238246
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "demoDeploymentBackup"),
239247
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
240248
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),

internal/integrationtest/golden_gate_deployment_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
325325

326326
func(s *terraform.State) (err error) {
327327
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
328-
if resId == resId2 {
329-
return fmt.Errorf("resource updated in place when it was supposed to be recreated for public access")
328+
if resId != resId2 {
329+
return fmt.Errorf("resource has been recreated meanwhile it was supposed to be updated")
330330
}
331331
return err
332332
},

internal/service/golden_gate/golden_gate_connection_data_source.go

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,96 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
438438
s.D.Set("time_updated", v.TimeUpdated.String())
439439
}
440440

441+
if v.VaultId != nil {
442+
s.D.Set("vault_id", *v.VaultId)
443+
}
444+
case oci_golden_gate.Db2Connection:
445+
s.D.Set("connection_type", "DB2")
446+
447+
additionalAttributes := []interface{}{}
448+
for _, item := range v.AdditionalAttributes {
449+
additionalAttributes = append(additionalAttributes, NameValuePairToMap(item))
450+
}
451+
s.D.Set("additional_attributes", additionalAttributes)
452+
453+
if v.DatabaseName != nil {
454+
s.D.Set("database_name", *v.DatabaseName)
455+
}
456+
457+
if v.Host != nil {
458+
s.D.Set("host", *v.Host)
459+
}
460+
461+
if v.Port != nil {
462+
s.D.Set("port", *v.Port)
463+
}
464+
465+
s.D.Set("security_protocol", v.SecurityProtocol)
466+
467+
s.D.Set("technology_type", v.TechnologyType)
468+
469+
if v.Username != nil {
470+
s.D.Set("username", *v.Username)
471+
}
472+
473+
if v.CompartmentId != nil {
474+
s.D.Set("compartment_id", *v.CompartmentId)
475+
}
476+
477+
if v.DefinedTags != nil {
478+
s.D.Set("defined_tags", tfresource.DefinedTagsToMap(v.DefinedTags))
479+
}
480+
481+
if v.Description != nil {
482+
s.D.Set("description", *v.Description)
483+
}
484+
485+
if v.DisplayName != nil {
486+
s.D.Set("display_name", *v.DisplayName)
487+
}
488+
489+
s.D.Set("freeform_tags", v.FreeformTags)
490+
491+
ingressIps := []interface{}{}
492+
for _, item := range v.IngressIps {
493+
ingressIps = append(ingressIps, IngressIpDetailsToMap(item))
494+
}
495+
s.D.Set("ingress_ips", ingressIps)
496+
497+
if v.KeyId != nil {
498+
s.D.Set("key_id", *v.KeyId)
499+
}
500+
501+
if v.LifecycleDetails != nil {
502+
s.D.Set("lifecycle_details", *v.LifecycleDetails)
503+
}
504+
505+
nsgIds := []interface{}{}
506+
for _, item := range v.NsgIds {
507+
nsgIds = append(nsgIds, item)
508+
}
509+
s.D.Set("nsg_ids", nsgIds)
510+
511+
s.D.Set("routing_method", v.RoutingMethod)
512+
513+
s.D.Set("state", v.LifecycleState)
514+
515+
if v.SubnetId != nil {
516+
s.D.Set("subnet_id", *v.SubnetId)
517+
}
518+
519+
if v.SystemTags != nil {
520+
s.D.Set("system_tags", tfresource.SystemTagsToMap(v.SystemTags))
521+
}
522+
523+
if v.TimeCreated != nil {
524+
s.D.Set("time_created", v.TimeCreated.String())
525+
}
526+
527+
if v.TimeUpdated != nil {
528+
s.D.Set("time_updated", v.TimeUpdated.String())
529+
}
530+
441531
if v.VaultId != nil {
442532
s.D.Set("vault_id", *v.VaultId)
443533
}
@@ -1391,7 +1481,6 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
13911481
if v.LifecycleDetails != nil {
13921482
s.D.Set("lifecycle_details", *v.LifecycleDetails)
13931483
}
1394-
13951484
nsgIds := []interface{}{}
13961485
for _, item := range v.NsgIds {
13971486
nsgIds = append(nsgIds, item)
@@ -1469,6 +1558,7 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
14691558
if v.LifecycleDetails != nil {
14701559
s.D.Set("lifecycle_details", *v.LifecycleDetails)
14711560
}
1561+
14721562
nsgIds := []interface{}{}
14731563
for _, item := range v.NsgIds {
14741564
nsgIds = append(nsgIds, item)
@@ -1501,6 +1591,8 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
15011591
case oci_golden_gate.OracleConnection:
15021592
s.D.Set("connection_type", "ORACLE")
15031593

1594+
s.D.Set("authentication_mode", v.AuthenticationMode)
1595+
15041596
if v.ConnectionString != nil {
15051597
s.D.Set("connection_string", *v.ConnectionString)
15061598
}
@@ -1673,6 +1765,10 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
16731765
s.D.Set("database_name", *v.DatabaseName)
16741766
}
16751767

1768+
if v.DbSystemId != nil {
1769+
s.D.Set("db_system_id", *v.DbSystemId)
1770+
}
1771+
16761772
if v.Host != nil {
16771773
s.D.Set("host", *v.Host)
16781774
}
@@ -1761,6 +1857,10 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
17611857

17621858
s.D.Set("authentication_type", v.AuthenticationType)
17631859

1860+
if v.RedisClusterId != nil {
1861+
s.D.Set("redis_cluster_id", *v.RedisClusterId)
1862+
}
1863+
17641864
s.D.Set("security_protocol", v.SecurityProtocol)
17651865

17661866
if v.Servers != nil {
@@ -1885,7 +1985,7 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
18851985
for _, item := range v.NsgIds {
18861986
nsgIds = append(nsgIds, item)
18871987
}
1888-
s.D.Set("nsg_ids", nsgIds)
1988+
s.D.Set("nsg_ids", schema.NewSet(tfresource.LiteralTypeHashCodeForSets, nsgIds))
18891989

18901990
s.D.Set("routing_method", v.RoutingMethod)
18911991

@@ -1899,6 +1999,8 @@ func (s *GoldenGateConnectionDataSourceCrud) SetData() error {
18991999
s.D.Set("system_tags", tfresource.SystemTagsToMap(v.SystemTags))
19002000
}
19012001

2002+
s.D.Set("technology_type", v.TechnologyType)
2003+
19022004
if v.TimeCreated != nil {
19032005
s.D.Set("time_created", v.TimeCreated.String())
19042006
}

0 commit comments

Comments
 (0)