Skip to content

Commit 3b4151c

Browse files
ROSHNI TIWARIvsin12
authored andcommitted
Added - Support for ExaCS | DBRS integration
1 parent 0fcf5c8 commit 3b4151c

19 files changed

+310
-23
lines changed

examples/database/db_systems/db_exacs/resources.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@ resource "oci_database_db_home" "test_db_home_vm_cluster" {
6767
display_name = "createdDbHome"
6868
}
6969

70+
resource "oci_database_db_home" "test_dbrs_db_home_vm_cluster" {
71+
vm_cluster_id = oci_database_cloud_vm_cluster.test_cloud_vm_cluster.id
72+
73+
database {
74+
admin_password = "BEstrO0ng_#11"
75+
db_name = "dbrsDb"
76+
character_set = "AL32UTF8"
77+
ncharacter_set = "AL16UTF16"
78+
db_workload = "OLTP"
79+
pdb_name = "pdbName"
80+
db_backup_config {
81+
auto_backup_enabled = "true"
82+
auto_backup_window = "SLOT_TWO"
83+
backup_deletion_policy = "DELETE_IMMEDIATELY"
84+
backup_destination_details {
85+
dbrs_policy_id = "dbrsPolicyOcid"
86+
type = "DBRS"
87+
}
88+
}
89+
freeform_tags = {
90+
"Department" = "Finance"
91+
}
92+
}
93+
94+
# VM_CLUSTER_BACKUP can also be specified as a source for cloud VM clusters.
95+
source = "VM_CLUSTER_NEW"
96+
db_version = "19.0.0.0"
97+
display_name = "createdDbrsDbHome"
98+
}
99+
100+
70101
resource "oci_database_db_home" "test_db_home_vm_cluster_no_db" {
71102
vm_cluster_id = oci_database_cloud_vm_cluster.test_cloud_vm_cluster.id
72103

examples/database/db_systems/db_exacs/variables.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ variable "private_key_path" {}
88
variable "region" {}
99

1010
variable "compartment_ocid" {}
11-
variable "ssh_public_key" {}
11+
12+
variable "ssh_public_key" {
13+
default = "ssh-rsa"
14+
}
1215
variable "ssh_private_key" {}
1316

1417
variable "cloud_exadata_infrastructure_shape" {

internal/integrationtest/database_database_test.go

Lines changed: 89 additions & 21 deletions
Large diffs are not rendered by default.

internal/service/database/database_database_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,18 @@ func (s *DatabaseDatabaseDataSourceCrud) SetData() error {
134134
s.D.Set("kms_key_version_id", *s.Res.KmsKeyVersionId)
135135
}
136136

137+
if s.Res.LastBackupDurationInSeconds != nil {
138+
s.D.Set("last_backup_duration_in_seconds", *s.Res.LastBackupDurationInSeconds)
139+
}
140+
137141
if s.Res.LastBackupTimestamp != nil {
138142
s.D.Set("last_backup_timestamp", s.Res.LastBackupTimestamp.String())
139143
}
140144

145+
if s.Res.LastFailedBackupTimestamp != nil {
146+
s.D.Set("last_failed_backup_timestamp", s.Res.LastFailedBackupTimestamp.String())
147+
}
148+
141149
if s.Res.LifecycleDetails != nil {
142150
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
143151
}

internal/service/database/database_database_resource.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func DatabaseDatabaseResource() *schema.Resource {
110110
Optional: true,
111111
Computed: true,
112112
},
113+
"backup_deletion_policy": {
114+
Type: schema.TypeString,
115+
Optional: true,
116+
Computed: true,
117+
ForceNew: true,
118+
},
113119
"backup_destination_details": {
114120
Type: schema.TypeList,
115121
Optional: true,
@@ -120,6 +126,12 @@ func DatabaseDatabaseResource() *schema.Resource {
120126
// Required
121127

122128
// Optional
129+
"dbrs_policy_id": {
130+
Type: schema.TypeString,
131+
Optional: true,
132+
Computed: true,
133+
ForceNew: true,
134+
},
123135
"id": {
124136
Type: schema.TypeString,
125137
Optional: true,
@@ -341,6 +353,10 @@ func DatabaseDatabaseResource() *schema.Resource {
341353
Type: schema.TypeString,
342354
Computed: true,
343355
},
356+
"backup_deletion_policy": {
357+
Type: schema.TypeString,
358+
Computed: true,
359+
},
344360
"backup_destination_details": {
345361
Type: schema.TypeList,
346362
Computed: true,
@@ -351,6 +367,10 @@ func DatabaseDatabaseResource() *schema.Resource {
351367
// Optional
352368

353369
// Computed
370+
"dbrs_policy_id": {
371+
Type: schema.TypeString,
372+
Computed: true,
373+
},
354374
"id": {
355375
Type: schema.TypeString,
356376
Computed: true,
@@ -403,10 +423,18 @@ func DatabaseDatabaseResource() *schema.Resource {
403423
Type: schema.TypeBool,
404424
Computed: true,
405425
},
426+
"last_backup_duration_in_seconds": {
427+
Type: schema.TypeInt,
428+
Computed: true,
429+
},
406430
"last_backup_timestamp": {
407431
Type: schema.TypeString,
408432
Computed: true,
409433
},
434+
"last_failed_backup_timestamp": {
435+
Type: schema.TypeString,
436+
Computed: true,
437+
},
410438
"lifecycle_details": {
411439
Type: schema.TypeString,
412440
Computed: true,
@@ -659,10 +687,18 @@ func (s *DatabaseDatabaseResourceCrud) SetData() error {
659687
s.D.Set("kms_key_version_id", *s.Res.KmsKeyVersionId)
660688
}
661689

690+
if s.Res.LastBackupDurationInSeconds != nil {
691+
s.D.Set("last_backup_duration_in_seconds", *s.Res.LastBackupDurationInSeconds)
692+
}
693+
662694
if s.Res.LastBackupTimestamp != nil {
663695
s.D.Set("last_backup_timestamp", s.Res.LastBackupTimestamp.String())
664696
}
665697

698+
if s.Res.LastFailedBackupTimestamp != nil {
699+
s.D.Set("last_failed_backup_timestamp", s.Res.LastFailedBackupTimestamp.String())
700+
}
701+
666702
if s.Res.LifecycleDetails != nil {
667703
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
668704
}
@@ -703,6 +739,11 @@ func (s *DatabaseDatabaseResourceCrud) SetData() error {
703739
func (s *DatabaseDatabaseResourceCrud) mapToBackupDestinationDetails(fieldKeyFormat string) (oci_database.BackupDestinationDetails, error) {
704740
result := oci_database.BackupDestinationDetails{}
705741

742+
if dbrsPolicyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "dbrs_policy_id")); ok {
743+
tmp := dbrsPolicyId.(string)
744+
result.DbrsPolicyId = &tmp
745+
}
746+
706747
if id, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "id")); ok {
707748
tmp := id.(string)
708749
result.Id = &tmp
@@ -728,6 +769,10 @@ func (s *DatabaseDatabaseResourceCrud) mapToBackupDestinationDetails(fieldKeyFor
728769
func BackupDestinationDetailsToMap(obj oci_database.BackupDestinationDetails) map[string]interface{} {
729770
result := map[string]interface{}{}
730771

772+
if obj.DbrsPolicyId != nil {
773+
result["dbrs_policy_id"] = string(*obj.DbrsPolicyId)
774+
}
775+
731776
if obj.Id != nil {
732777
result["id"] = string(*obj.Id)
733778
}
@@ -912,6 +957,10 @@ func (s *DatabaseDatabaseResourceCrud) mapToDbBackupConfig(fieldKeyFormat string
912957
result.AutoBackupWindow = oci_database.DbBackupConfigAutoBackupWindowEnum(autoBackupWindow.(string))
913958
}
914959

960+
if backupDeletionPolicy, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_deletion_policy")); ok {
961+
result.BackupDeletionPolicy = oci_database.DbBackupConfigBackupDeletionPolicyEnum(backupDeletionPolicy.(string))
962+
}
963+
915964
if backupDestinationDetails, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_destination_details")); ok {
916965
interfaces := backupDestinationDetails.([]interface{})
917966
tmp := make([]oci_database.BackupDestinationDetails, len(interfaces))

internal/service/database/database_database_upgrade_resource.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ func DatabaseDatabaseUpgradeResource() *schema.Resource {
144144
Type: schema.TypeString,
145145
Computed: true,
146146
},
147+
"backup_deletion_policy": {
148+
Type: schema.TypeString,
149+
Computed: true,
150+
},
147151
"backup_destination_details": {
148152
Type: schema.TypeList,
149153
Computed: true,
@@ -154,6 +158,10 @@ func DatabaseDatabaseUpgradeResource() *schema.Resource {
154158
// Optional
155159

156160
// Computed
161+
"dbrs_policy_id": {
162+
Type: schema.TypeString,
163+
Computed: true,
164+
},
157165
"id": {
158166
Type: schema.TypeString,
159167
Computed: true,
@@ -226,10 +234,18 @@ func DatabaseDatabaseUpgradeResource() *schema.Resource {
226234
Type: schema.TypeString,
227235
Computed: true,
228236
},
237+
"last_backup_duration_in_seconds": {
238+
Type: schema.TypeInt,
239+
Computed: true,
240+
},
229241
"last_backup_timestamp": {
230242
Type: schema.TypeString,
231243
Computed: true,
232244
},
245+
"last_failed_backup_timestamp": {
246+
Type: schema.TypeString,
247+
Computed: true,
248+
},
233249
"lifecycle_details": {
234250
Type: schema.TypeString,
235251
Computed: true,
@@ -428,10 +444,18 @@ func (s *DatabaseDatabaseUpgradeResourceCrud) SetData() error {
428444
s.D.Set("kms_key_version_id", *s.Res.KmsKeyVersionId)
429445
}
430446

447+
if s.Res.LastBackupDurationInSeconds != nil {
448+
s.D.Set("last_backup_duration_in_seconds", *s.Res.LastBackupDurationInSeconds)
449+
}
450+
431451
if s.Res.LastBackupTimestamp != nil {
432452
s.D.Set("last_backup_timestamp", s.Res.LastBackupTimestamp.String())
433453
}
434454

455+
if s.Res.LastFailedBackupTimestamp != nil {
456+
s.D.Set("last_failed_backup_timestamp", s.Res.LastFailedBackupTimestamp.String())
457+
}
458+
435459
if s.Res.LifecycleDetails != nil {
436460
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
437461
}

internal/service/database/database_databases_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,18 @@ func (s *DatabaseDatabasesDataSourceCrud) SetData() error {
196196
database["kms_key_version_id"] = *r.KmsKeyVersionId
197197
}
198198

199+
if r.LastBackupDurationInSeconds != nil {
200+
database["last_backup_duration_in_seconds"] = *r.LastBackupDurationInSeconds
201+
}
202+
199203
if r.LastBackupTimestamp != nil {
200204
database["last_backup_timestamp"] = r.LastBackupTimestamp.String()
201205
}
202206

207+
if r.LastFailedBackupTimestamp != nil {
208+
database["last_failed_backup_timestamp"] = r.LastFailedBackupTimestamp.String()
209+
}
210+
203211
if r.LifecycleDetails != nil {
204212
database["lifecycle_details"] = *r.LifecycleDetails
205213
}

internal/service/database/database_db_home_resource.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ func DatabaseDbHomeResource() *schema.Resource {
106106
Optional: true,
107107
Computed: true,
108108
},
109+
"backup_deletion_policy": {
110+
Type: schema.TypeString,
111+
Optional: true,
112+
Computed: true,
113+
ForceNew: true,
114+
},
109115
"backup_destination_details": {
110116
Type: schema.TypeList,
111117
Optional: true,
@@ -116,6 +122,12 @@ func DatabaseDbHomeResource() *schema.Resource {
116122
// Required
117123

118124
// Optional
125+
"dbrs_policy_id": {
126+
Type: schema.TypeString,
127+
Optional: true,
128+
Computed: true,
129+
ForceNew: true,
130+
},
119131
"id": {
120132
Type: schema.TypeString,
121133
Optional: true,
@@ -729,6 +741,11 @@ func (s *DatabaseDbHomeResourceCrud) SetData() error {
729741
func (s *DatabaseDbHomeResourceCrud) mapToBackupDestinationDetails(fieldKeyFormat string) (oci_database.BackupDestinationDetails, error) {
730742
result := oci_database.BackupDestinationDetails{}
731743

744+
if dbrsPolicyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "dbrs_policy_id")); ok {
745+
tmp := dbrsPolicyId.(string)
746+
result.DbrsPolicyId = &tmp
747+
}
748+
732749
if id, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "id")); ok {
733750
tmp := id.(string)
734751
result.Id = &tmp
@@ -903,6 +920,10 @@ func (s *DatabaseDbHomeResourceCrud) mapToDbBackupConfig(fieldKeyFormat string)
903920
}
904921
}
905922

923+
if backupDeletionPolicy, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_deletion_policy")); ok {
924+
result.BackupDeletionPolicy = oci_database.DbBackupConfigBackupDeletionPolicyEnum(backupDeletionPolicy.(string))
925+
}
926+
906927
if backupDestinationDetails, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_destination_details")); ok {
907928
result.BackupDestinationDetails = []oci_database.BackupDestinationDetails{}
908929
interfaces := backupDestinationDetails.([]interface{})

internal/service/database/database_db_system_resource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ func DatabaseDbSystemResource() *schema.Resource {
123123
Optional: true,
124124
Computed: true,
125125
},
126+
"backup_deletion_policy": {
127+
Type: schema.TypeString,
128+
Optional: true,
129+
Computed: true,
130+
ForceNew: true,
131+
},
126132
"backup_destination_details": {
127133
Type: schema.TypeList,
128134
Optional: true,
@@ -132,6 +138,12 @@ func DatabaseDbSystemResource() *schema.Resource {
132138
// Required
133139

134140
// Optional
141+
"dbrs_policy_id": {
142+
Type: schema.TypeString,
143+
Optional: true,
144+
Computed: true,
145+
ForceNew: true,
146+
},
135147
"id": {
136148
Type: schema.TypeString,
137149
Optional: true,
@@ -1441,6 +1453,11 @@ func (s *DatabaseDbSystemResourceCrud) SetData() error {
14411453
func (s *DatabaseDbSystemResourceCrud) mapToBackupDestinationDetails(fieldKeyFormat string) (oci_database.BackupDestinationDetails, error) {
14421454
result := oci_database.BackupDestinationDetails{}
14431455

1456+
if dbrsPolicyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "dbrs_policy_id")); ok {
1457+
tmp := dbrsPolicyId.(string)
1458+
result.DbrsPolicyId = &tmp
1459+
}
1460+
14441461
if id, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "id")); ok {
14451462
tmp := id.(string)
14461463
result.Id = &tmp
@@ -2044,6 +2061,10 @@ func (s *DatabaseDbSystemResourceCrud) mapToDbBackupConfig(fieldKeyFormat string
20442061
}
20452062
}
20462063

2064+
if backupDeletionPolicy, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_deletion_policy")); ok {
2065+
result.BackupDeletionPolicy = oci_database.DbBackupConfigBackupDeletionPolicyEnum(backupDeletionPolicy.(string))
2066+
}
2067+
20472068
if backupDestinationDetails, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backup_destination_details")); ok {
20482069
interfaces := backupDestinationDetails.([]interface{})
20492070
tmp := make([]oci_database.BackupDestinationDetails, len(interfaces))
@@ -2078,6 +2099,8 @@ func DbBackupConfigToMap(obj *oci_database.DbBackupConfig) map[string]interface{
20782099

20792100
result["auto_backup_window"] = string(obj.AutoBackupWindow)
20802101

2102+
result["backup_deletion_policy"] = string(obj.BackupDeletionPolicy)
2103+
20812104
backupDestinationDetails := []interface{}{}
20822105
for _, item := range obj.BackupDestinationDetails {
20832106
backupDestinationDetails = append(backupDestinationDetails, BackupDestinationDetailsToMap(item))

website/docs/d/database_autonomous_container_database.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The following attributes are exported:
3838
* `available_cpus` - Sum of OCPUs available on the Autonomous VM Cluster + Sum of reclaimable OCPUs available in the Autonomous Container Database.
3939
* `backup_config` - Backup options for the Autonomous Container Database.
4040
* `backup_destination_details` - Backup destination details.
41+
* `dbrs_policy_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the DBRS policy used for backup.
4142
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the backup destination.
4243
* `internet_proxy` - Proxy URL to connect to object store.
4344
* `type` - Type of the database backup destination.

0 commit comments

Comments
 (0)