Skip to content

Commit 7498e69

Browse files
Tom O'Shaughnessyjotruon
authored andcommitted
Added - Support for GoldenGate deployment upgrades
1 parent 983c98a commit 7498e69

18 files changed

+859
-117
lines changed

examples/goldengate/Deployment/main.tf

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ variable "deployment_cpu_core_count" {
2020
default = 1
2121
}
2222

23-
variable "deployment_defined_tags_value" {
24-
default = "value"
25-
}
26-
2723
variable "deployment_deployment_type" {
2824
default = "OGG"
2925
}
@@ -37,7 +33,6 @@ variable "deployment_display_name" {
3733
}
3834

3935
variable "deployment_fqdn" {
40-
default = "fqdn.ggs.com"
4136
}
4237

4338
variable "deployment_freeform_tags" {
@@ -69,20 +64,16 @@ variable "deployment_ogg_data_deployment_name" {
6964
}
7065

7166
variable "deployment_ogg_data_certificate" {
72-
default = "certificate"
7367
}
7468

7569
variable "deployment_ogg_data_key" {
76-
default = "key"
7770
}
7871

7972
variable "deployment_state" {
8073
default = "ACTIVE"
8174
}
8275

83-
variable defined_tag_namespace_name { default = "" }
84-
85-
76+
#variable defined_tag_namespace_name { default = "" }
8677

8778
provider "oci" {
8879
tenancy_ocid = var.tenancy_ocid
@@ -100,6 +91,7 @@ resource "oci_core_network_security_group" "test_network_security_group" {
10091

10192
resource "oci_core_subnet" "test_subnet" {
10293
cidr_block = "10.0.0.0/24"
94+
display_name = "TestSubnet"
10395
compartment_id = var.compartment_ocid
10496
vcn_id = oci_core_vcn.test_vcn.id
10597
}
@@ -123,25 +115,9 @@ resource "oci_golden_gate_deployment_backup" "test_deployment_backup" {
123115

124116
}
125117

126-
resource "oci_identity_tag_namespace" "tag-namespace1" {
127-
#Required
128-
compartment_id = var.tenancy_ocid
129-
description = "example tag namespace"
130-
name = var.defined_tag_namespace_name != "" ? var.defined_tag_namespace_name : "example-tag-namespace-all"
131-
is_retired = false
132-
}
133-
134-
resource "oci_identity_tag" "tag1" {
135-
#Required
136-
description = "example tag"
137-
name = "example-tag"
138-
tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id
139-
is_retired = false
140-
}
141-
142118
resource "oci_objectstorage_bucket" "test_bucket" {
143119
compartment_id = var.compartment_ocid
144-
name = "tfTestBucket"
120+
name = "tfTestBucketold"
145121
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
146122
}
147123

@@ -153,13 +129,12 @@ resource "oci_golden_gate_deployment" "test_backup_deployment" {
153129
display_name = var.deployment_display_name
154130
is_auto_scaling_enabled = var.deployment_is_auto_scaling_enabled
155131
license_model = var.deployment_license_model
156-
subnet_id = oci_core_subnet.test_subnet.id
132+
subnet_id = oci_core_subnet.test_subnet.id
157133
ogg_data {
158134
admin_password = var.deployment_ogg_data_admin_password
159135
admin_username = var.deployment_ogg_data_admin_username
160136
deployment_name = var.deployment_ogg_data_deployment_name
161137
}
162-
163138
}
164139

165140
resource "oci_golden_gate_deployment" "test_deployment" {
@@ -187,8 +162,8 @@ resource "oci_golden_gate_deployment" "test_deployment" {
187162
deployment_name = var.deployment_ogg_data_deployment_name
188163

189164
#Optional
190-
certificate = var.deployment_ogg_data_certificate
191-
key = var.deployment_ogg_data_key
165+
#certificate = var.deployment_ogg_data_certificate
166+
#key = var.deployment_ogg_data_key
192167
}
193168
}
194169

oci/export_definitions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,8 @@ var exportGoldenGateDatabaseRegistrationHints = &TerraformResourceHints{
15571557
requireResourceRefresh: true,
15581558
discoverableLifecycleStates: []string{
15591559
string(oci_golden_gate.LifecycleStateActive),
1560+
string(oci_golden_gate.LifecycleStateNeedsAttention),
1561+
string(oci_golden_gate.LifecycleStateSucceeded),
15601562
},
15611563
}
15621564

@@ -1569,6 +1571,8 @@ var exportGoldenGateDeploymentHints = &TerraformResourceHints{
15691571
requireResourceRefresh: true,
15701572
discoverableLifecycleStates: []string{
15711573
string(oci_golden_gate.LifecycleStateActive),
1574+
string(oci_golden_gate.LifecycleStateNeedsAttention),
1575+
string(oci_golden_gate.LifecycleStateSucceeded),
15721576
},
15731577
}
15741578

@@ -1581,6 +1585,8 @@ var exportGoldenGateDeploymentBackupHints = &TerraformResourceHints{
15811585
requireResourceRefresh: true,
15821586
discoverableLifecycleStates: []string{
15831587
string(oci_golden_gate.LifecycleStateActive),
1588+
string(oci_golden_gate.LifecycleStateNeedsAttention),
1589+
string(oci_golden_gate.LifecycleStateSucceeded),
15841590
},
15851591
}
15861592

oci/golden_gate_database_registration_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,15 @@ func (s *GoldenGateDatabaseRegistrationResourceCrud) ID() string {
206206
func (s *GoldenGateDatabaseRegistrationResourceCrud) CreatedPending() []string {
207207
return []string{
208208
string(oci_golden_gate.LifecycleStateCreating),
209+
string(oci_golden_gate.LifecycleStateInProgress),
209210
}
210211
}
211212

212213
func (s *GoldenGateDatabaseRegistrationResourceCrud) CreatedTarget() []string {
213214
return []string{
214215
string(oci_golden_gate.LifecycleStateActive),
216+
string(oci_golden_gate.LifecycleStateNeedsAttention),
217+
string(oci_golden_gate.LifecycleStateSucceeded),
215218
}
216219
}
217220

oci/golden_gate_database_registration_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ var (
6060
"alias_name": Representation{repType: Required, create: `aliasName1`, update: `aliasName2`},
6161
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
6262
"display_name": Representation{repType: Required, create: `displayName`, update: `displayName2`},
63-
"fqdn": Representation{repType: Required, create: `fqdn`, update: `fqdn2`},
63+
"fqdn": Representation{repType: Required, create: `fqdn.example.com`, update: `fqdn2.example.com`},
6464
"password": Representation{repType: Required, create: `BEstrO0ng_#11`, update: `BEstrO0ng_#12`},
6565
"username": Representation{repType: Required, create: `username`, update: `username2`},
6666
"connection_string": Representation{repType: Optional, create: `connectionString`, update: `connectionString2`},
6767
"database_id": Representation{repType: Optional, create: `${data.oci_database_databases.t.databases.0.id}`},
68-
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
6968
"description": Representation{repType: Optional, create: `description`, update: `description2`},
7069
"freeform_tags": Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
7170
//IP address from db Nodes need vnic_id, which is null because of using test header purposes
@@ -75,10 +74,15 @@ var (
7574
"subnet_id": Representation{repType: Optional, create: `${oci_core_subnet.test_subnet.id}`},
7675
"vault_id": Representation{repType: Optional, create: `${var.kms_vault_id}`},
7776
"wallet": Representation{repType: Optional, create: `wallet`, update: `wallet2`},
77+
"lifecycle": RepresentationGroup{Required, ignoreGGSDefinedTagsChangesRepresentation},
78+
}
79+
80+
ignoreGGSDefinedTagsChangesRepresentation = map[string]interface{}{
81+
"ignore_changes": Representation{repType: Required, create: []string{`defined_tags`}},
7882
}
7983

8084
goldenGateDbSystemRepresentation = map[string]interface{}{
81-
"availability_domain": Representation{repType: Required, create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.2.name}")}`},
85+
"availability_domain": Representation{repType: Required, create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`},
8286
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
8387
"database_edition": Representation{repType: Required, create: `ENTERPRISE_EDITION`},
8488
"db_home": RepresentationGroup{Required, goldenGateDbSystemDbHomeRepresentation},
@@ -99,7 +103,7 @@ var (
99103

100104
goldenGateDbSystemDbHomeRepresentation = map[string]interface{}{
101105
"database": RepresentationGroup{Required, goldenGateDatabaseRepresentation},
102-
"db_version": Representation{repType: Required, create: `21.1.0.0`},
106+
"db_version": Representation{repType: Required, create: `21.3.0.0`},
103107
}
104108

105109
goldenGateDatabaseRepresentation = map[string]interface{}{
@@ -153,7 +157,7 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
153157
resource.TestCheckResourceAttr(resourceName, "alias_name", "aliasName1"),
154158
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
155159
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
156-
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn"),
160+
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn.example.com"),
157161
resource.TestCheckResourceAttr(resourceName, "password", "BEstrO0ng_#11"),
158162
resource.TestCheckResourceAttr(resourceName, "username", "username"),
159163

@@ -177,10 +181,9 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
177181
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
178182
resource.TestCheckResourceAttr(resourceName, "connection_string", "connectionString"),
179183
resource.TestCheckResourceAttrSet(resourceName, "database_id"),
180-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
181184
resource.TestCheckResourceAttr(resourceName, "description", "description"),
182185
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
183-
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn"),
186+
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn.example.com"),
184187
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
185188
resource.TestCheckResourceAttrSet(resourceName, "id"),
186189
// resource.TestCheckResourceAttr(resourceName, "ip_address", "ipAddress"),
@@ -216,10 +219,9 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
216219
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
217220
resource.TestCheckResourceAttr(resourceName, "connection_string", "connectionString"),
218221
resource.TestCheckResourceAttrSet(resourceName, "database_id"),
219-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
220222
resource.TestCheckResourceAttr(resourceName, "description", "description"),
221223
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
222-
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn"),
224+
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn.example.com"),
223225
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
224226
resource.TestCheckResourceAttrSet(resourceName, "id"),
225227
// resource.TestCheckResourceAttr(resourceName, "ip_address", "ipAddress"),
@@ -249,10 +251,9 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
249251
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
250252
resource.TestCheckResourceAttr(resourceName, "connection_string", "connectionString2"),
251253
resource.TestCheckResourceAttrSet(resourceName, "database_id"),
252-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
253254
resource.TestCheckResourceAttr(resourceName, "description", "description2"),
254255
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
255-
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn2"),
256+
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn2.example.com"),
256257
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
257258
resource.TestCheckResourceAttrSet(resourceName, "id"),
258259
// resource.TestCheckResourceAttr(resourceName, "ip_address", "ipAddress"),
@@ -298,10 +299,9 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
298299
resource.TestCheckResourceAttr(singularDatasourceName, "alias_name", "aliasName2"),
299300
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
300301
resource.TestCheckResourceAttr(singularDatasourceName, "connection_string", "connectionString2"),
301-
resource.TestCheckResourceAttr(singularDatasourceName, "defined_tags.%", "1"),
302302
resource.TestCheckResourceAttr(singularDatasourceName, "description", "description2"),
303303
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName2"),
304-
resource.TestCheckResourceAttr(singularDatasourceName, "fqdn", "fqdn2"),
304+
resource.TestCheckResourceAttr(singularDatasourceName, "fqdn", "fqdn2.example.com"),
305305
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
306306
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
307307
//resource.TestCheckResourceAttr(singularDatasourceName, "ip_address", "ipAddress"),

oci/golden_gate_deployment_backup_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,15 @@ func (s *GoldenGateDeploymentBackupResourceCrud) ID() string {
167167
func (s *GoldenGateDeploymentBackupResourceCrud) CreatedPending() []string {
168168
return []string{
169169
string(oci_golden_gate.LifecycleStateCreating),
170+
string(oci_golden_gate.LifecycleStateInProgress),
170171
}
171172
}
172173

173174
func (s *GoldenGateDeploymentBackupResourceCrud) CreatedTarget() []string {
174175
return []string{
175176
string(oci_golden_gate.LifecycleStateActive),
177+
string(oci_golden_gate.LifecycleStateNeedsAttention),
178+
string(oci_golden_gate.LifecycleStateSucceeded),
176179
}
177180
}
178181

oci/golden_gate_deployment_backup_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232

3333
deploymentBackupDataSourceRepresentation = map[string]interface{}{
3434
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
35-
"deployment_id": Representation{repType: Optional, create: `${oci_golden_gate_deployment.test_backup_deployment.id}`},
35+
"deployment_id": Representation{repType: Optional, create: `${oci_golden_gate_deployment.test_ggsdeployment.id}`},
3636
"display_name": Representation{repType: Optional, create: `demoDeploymentBackup`},
3737
"state": Representation{repType: Optional, create: `ACTIVE`},
3838
"filter": RepresentationGroup{Required, deploymentBackupDataSourceFilterRepresentation}}
@@ -44,18 +44,21 @@ var (
4444
deploymentBackupRepresentation = map[string]interface{}{
4545
"bucket": Representation{repType: Required, create: `${oci_objectstorage_bucket.test_bucket.name}`},
4646
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
47-
"deployment_id": Representation{repType: Required, create: `${oci_golden_gate_deployment.test_backup_deployment.id}`},
47+
"deployment_id": Representation{repType: Required, create: `${oci_golden_gate_deployment.test_ggsdeployment.id}`},
4848
"display_name": Representation{repType: Required, create: `demoDeploymentBackup`},
4949
"namespace": Representation{repType: Required, create: `${data.oci_objectstorage_namespace.test_namespace.namespace}`},
5050
"object": Representation{repType: Required, create: `object`},
51-
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
5251
"freeform_tags": Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
52+
"lifecycle": RepresentationGroup{Required, ignoreGGSDefinedTagsChangesRepresentation2},
53+
}
54+
55+
ignoreGGSDefinedTagsChangesRepresentation2 = map[string]interface{}{
56+
"ignore_changes": Representation{repType: Required, create: []string{`defined_tags`}},
5357
}
5458

5559
DeploymentBackupResourceDependencies = generateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", Required, Create, subnetRepresentation) +
5660
generateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", Required, Create, vcnRepresentation) +
57-
generateResourceFromRepresentationMap("oci_golden_gate_deployment", "test_backup_deployment", Required, Create, goldenGateDeploymentRepresentation) +
58-
DefinedTagsDependencies +
61+
generateResourceFromRepresentationMap("oci_golden_gate_deployment", "test_ggsdeployment", Required, Create, goldenGateDeploymentRepresentation) +
5962
generateResourceFromRepresentationMap("oci_objectstorage_bucket", "test_bucket", Required, Create, bucketRepresentation) +
6063
generateDataSourceFromRepresentationMap("oci_objectstorage_namespace", "test_namespace", Required, Create, namespaceSingularDataSourceRepresentation)
6164
)
@@ -116,7 +119,6 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
116119
Check: ComposeAggregateTestCheckFuncWrapper(
117120
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
118121
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
119-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
120122
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
121123
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
122124
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -148,7 +150,6 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
148150
Check: ComposeAggregateTestCheckFuncWrapper(
149151
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
150152
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
151-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
152153
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
153154
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
154155
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -175,7 +176,6 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
175176
Check: ComposeAggregateTestCheckFuncWrapper(
176177
resource.TestCheckResourceAttrSet(resourceName, "bucket"),
177178
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
178-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
179179
resource.TestCheckResourceAttrSet(resourceName, "deployment_id"),
180180
resource.TestCheckResourceAttr(resourceName, "display_name", "demoDeploymentBackup"),
181181
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -221,7 +221,6 @@ func TestGoldenGateDeploymentBackupResource_basic(t *testing.T) {
221221
resource.TestCheckResourceAttrSet(singularDatasourceName, "backup_type"),
222222
resource.TestCheckResourceAttrSet(singularDatasourceName, "bucket"),
223223
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
224-
resource.TestCheckResourceAttr(singularDatasourceName, "defined_tags.%", "1"),
225224
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "demoDeploymentBackup"),
226225
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
227226
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),

oci/golden_gate_deployment_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ func (s *GoldenGateDeploymentDataSourceCrud) SetData() error {
125125
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
126126
}
127127

128+
s.D.Set("lifecycle_sub_state", s.Res.LifecycleSubState)
129+
128130
s.D.Set("nsg_ids", s.Res.NsgIds)
129131

130132
if s.Res.OggData != nil {
@@ -159,5 +161,9 @@ func (s *GoldenGateDeploymentDataSourceCrud) SetData() error {
159161
s.D.Set("time_updated", s.Res.TimeUpdated.String())
160162
}
161163

164+
if s.Res.TimeUpgradeRequired != nil {
165+
s.D.Set("time_upgrade_required", s.Res.TimeUpgradeRequired.String())
166+
}
167+
162168
return nil
163169
}

0 commit comments

Comments
 (0)