Skip to content

Commit a01b286

Browse files
Terraform Team AutomationMeharwadeDivya
authored andcommitted
Bug Fix - Add polling for PDB resources.
1 parent 95091b0 commit a01b286

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

examples/database/db_systems/db_exacs/resources.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,29 @@ resource "oci_database_application_vip" "test_application_vip" {
137137

138138
#Optional
139139
db_node_id = data.oci_database_db_nodes.db_nodes.db_nodes[0]["id"]
140+
}
141+
142+
resource "oci_database_database" "test_database" {
143+
#Required
144+
database {
145+
admin_password = "BEstrO0ng_#11"
146+
db_name = "TFdb2Exa"
147+
character_set = "AL32UTF8"
148+
ncharacter_set = "AL16UTF16"
149+
db_workload = "OLTP"
150+
151+
db_backup_config {
152+
auto_backup_enabled = false
153+
}
154+
}
155+
156+
db_home_id = oci_database_db_home.test_db_home_vm_cluster_no_db.id
157+
source = "NONE"
158+
}
159+
160+
resource "oci_database_pluggable_database" "test_pluggable_database" {
161+
container_database_id = oci_database_database.test_database.id
162+
pdb_admin_password = "BEstrO0ng_#11"
163+
pdb_name = "SalesPdb"
164+
tde_wallet_password = "BEstrO0ng_#11"
140165
}

internal/service/database/database_pluggable_database_resource.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111

1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1313

14+
oci_work_requests "github.com/oracle/oci-go-sdk/v65/workrequests"
15+
1416
oci_database "github.com/oracle/oci-go-sdk/v65/database"
1517
)
1618

@@ -148,6 +150,7 @@ func createDatabasePluggableDatabase(d *schema.ResourceData, m interface{}) erro
148150
sync := &DatabasePluggableDatabaseResourceCrud{}
149151
sync.D = d
150152
sync.Client = m.(*client.OracleClients).DatabaseClient()
153+
sync.WorkRequestClient = m.(*client.OracleClients).WorkRequestClient
151154

152155
return tfresource.CreateResource(d, sync)
153156
}
@@ -181,6 +184,7 @@ type DatabasePluggableDatabaseResourceCrud struct {
181184
tfresource.BaseCrud
182185
Client *oci_database.DatabaseClient
183186
Res *oci_database.PluggableDatabase
187+
WorkRequestClient *oci_work_requests.WorkRequestClient
184188
DisableNotFoundRetries bool
185189
}
186190

@@ -260,7 +264,24 @@ func (s *DatabasePluggableDatabaseResourceCrud) Create() error {
260264
}
261265

262266
s.Res = &response.PluggableDatabase
263-
return nil
267+
workId := response.OpcWorkRequestId
268+
if workId != nil {
269+
var identifier *string
270+
var err error
271+
identifier = response.Id
272+
if identifier != nil {
273+
s.D.SetId(*identifier)
274+
}
275+
identifier, err = tfresource.WaitForWorkRequestWithErrorHandling(s.WorkRequestClient, workId, "pluggableDatabase", oci_work_requests.WorkRequestResourceActionTypeCreated, s.D.Timeout(schema.TimeoutCreate), s.DisableNotFoundRetries)
276+
if identifier != nil {
277+
s.D.SetId(*identifier)
278+
}
279+
if err != nil {
280+
return err
281+
}
282+
}
283+
284+
return s.Get()
264285
}
265286

266287
func (s *DatabasePluggableDatabaseResourceCrud) Get() error {

0 commit comments

Comments
 (0)