Skip to content

Commit 06c3458

Browse files
Terraform Team Automationravinitp
authored andcommitted
Added - Support for Support for running OCI OSS operation
1 parent 28c84da commit 06c3458

11 files changed

+107
-13
lines changed

examples/disaster_recovery/dr_protection_group/bucket.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ data "oci_objectstorage_namespace" "test_namespace" {
2020
data "oci_objectstorage_bucket" "test_bucket" {
2121
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
2222
name = var.bucket_name
23+
}
24+
25+
data "oci_objectstorage_bucket" "test_member_bucket" {
26+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
27+
name = "example-bucket-source"
2328
}

examples/disaster_recovery/dr_protection_group/dr_protection_group.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ variable "dr_protection_group_members_member_type" {
4949
default = "VOLUME_GROUP"
5050
}
5151

52+
variable "dr_protection_group_members_member_type_object_storage" {
53+
default = "OBJECT_STORAGE_BUCKET"
54+
}
55+
5256
variable "dr_protection_group_state" {
5357
default = "ACTIVE"
5458
}
@@ -80,6 +84,14 @@ resource "oci_disaster_recovery_dr_protection_group" "test_peer" {
8084
#Optional
8185
is_movable = var.dr_protection_group_members_is_movable
8286
}
87+
88+
members {
89+
#Required
90+
member_id = data.oci_objectstorage_bucket.test_member_bucket.bucket_id
91+
member_type = var.dr_protection_group_members_member_type_object_storage
92+
bucket = data.oci_objectstorage_bucket.test_member_bucket.name
93+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
94+
}
8395
}
8496

8597
resource "oci_disaster_recovery_dr_protection_group" "test_dr_protection_group" {

internal/integrationtest/disaster_recovery_dr_plan_execution_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
"dr_plan_execution_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_disaster_recovery_dr_plan_execution.test_dr_plan_execution.id}`},
3636
}
3737

38+
//Dr Plan Data source
3839
DisasterRecoveryDisasterRecoveryDrPlanExecutionDataSourceRepresentation = map[string]interface{}{
3940
"dr_protection_group_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_disaster_recovery_dr_protection_group.test_peer.id}`},
4041
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `Precheck Switchover from PHX to IAD`, Update: `displayName2`},

internal/integrationtest/disaster_recovery_dr_plan_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
"dr_plan_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_disaster_recovery_dr_plan.test_dr_plan.id}`},
3636
}
3737

38+
//Dr Plan Data source
3839
DisasterRecoveryDisasterRecoveryDrPlanDataSourceRepresentation = map[string]interface{}{
3940
"dr_protection_group_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_disaster_recovery_dr_protection_group.test_peer.id}`},
4041
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `Switchover from PHX to IAD`, Update: `displayName2`},
@@ -124,7 +125,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
124125
resource.TestCheckResourceAttrSet(resourceName, "id"),
125126
resource.TestCheckResourceAttrSet(resourceName, "peer_dr_protection_group_id"),
126127
resource.TestCheckResourceAttrSet(resourceName, "peer_region"),
127-
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "5"),
128+
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "3"),
128129
resource.TestCheckResourceAttrSet(resourceName, "state"),
129130
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
130131
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -155,7 +156,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
155156
resource.TestCheckResourceAttrSet(resourceName, "id"),
156157
resource.TestCheckResourceAttrSet(resourceName, "peer_dr_protection_group_id"),
157158
resource.TestCheckResourceAttrSet(resourceName, "peer_region"),
158-
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "5"),
159+
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "3"),
159160
resource.TestCheckResourceAttrSet(resourceName, "state"),
160161
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
161162
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -204,7 +205,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
204205
resource.TestCheckNoResourceAttr(singularDatasourceName, "life_cycle_details"),
205206
resource.TestCheckResourceAttrSet(singularDatasourceName, "peer_dr_protection_group_id"),
206207
resource.TestCheckResourceAttrSet(singularDatasourceName, "peer_region"),
207-
resource.TestCheckResourceAttr(singularDatasourceName, "plan_groups.#", "5"),
208+
resource.TestCheckResourceAttr(singularDatasourceName, "plan_groups.#", "3"),
208209
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
209210
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
210211
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_updated"),

internal/integrationtest/disaster_recovery_dr_protection_group_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ var (
7979
}
8080

8181
DisasterRecoveryDrProtectionGroupMembersRepresentation = map[string]interface{}{
82-
"member_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_core_volume_groups.test_volume_groups.volume_groups.0.id}`},
83-
"member_type": acctest.Representation{RepType: acctest.Required, Create: `VOLUME_GROUP`},
82+
"member_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_objectstorage_bucket.test_member_bucket.bucket_id}`},
83+
"member_type": acctest.Representation{RepType: acctest.Required, Create: `OBJECT_STORAGE_BUCKET`},
84+
"bucket": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_objectstorage_bucket.test_member_bucket.name}`},
85+
"namespace": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_objectstorage_namespace.test_namespace.namespace}`},
8486
}
8587

8688
DisasterRecoveryDrProtectionGroupWithComputeMemberConfig = `
@@ -113,6 +115,10 @@ var (
113115
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
114116
name = "testBucketName_1"
115117
}
118+
data "oci_objectstorage_bucket" "test_member_bucket" {
119+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
120+
name = "example-bucket-source"
121+
}
116122
`
117123

118124
VolumeGroupDependencyConfig = `
@@ -205,7 +211,7 @@ func TestDisasterRecoveryDrProtectionGroupResource_basic(t *testing.T) {
205211
resource.TestCheckResourceAttrSet(resourceName, "log_location.0.namespace"),
206212
resource.TestCheckResourceAttr(resourceName, "members.#", "1"),
207213
resource.TestCheckResourceAttrSet(resourceName, "members.0.member_id"),
208-
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "VOLUME_GROUP"),
214+
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "OBJECT_STORAGE_BUCKET"),
209215

210216
func(s *terraform.State) (err error) {
211217
resId, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -277,7 +283,7 @@ func TestDisasterRecoveryDrProtectionGroupResource_basic(t *testing.T) {
277283
resource.TestCheckResourceAttrSet(resourceName, "log_location.0.namespace"),
278284
resource.TestCheckResourceAttr(resourceName, "members.#", "1"),
279285
resource.TestCheckResourceAttrSet(resourceName, "members.0.member_id"),
280-
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "VOLUME_GROUP"),
286+
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "OBJECT_STORAGE_BUCKET"),
281287
resource.TestCheckResourceAttrSet(resourceName, "role"),
282288
resource.TestCheckResourceAttrSet(resourceName, "state"),
283289
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -316,7 +322,7 @@ func TestDisasterRecoveryDrProtectionGroupResource_basic(t *testing.T) {
316322
resource.TestCheckResourceAttrSet(resourceName, "log_location.0.namespace"),
317323
resource.TestCheckResourceAttr(resourceName, "members.#", "1"),
318324
resource.TestCheckResourceAttrSet(resourceName, "members.0.member_id"),
319-
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "VOLUME_GROUP"),
325+
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "OBJECT_STORAGE_BUCKET"),
320326
resource.TestCheckResourceAttrSet(resourceName, "role"),
321327
resource.TestCheckResourceAttrSet(resourceName, "state"),
322328
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -350,7 +356,7 @@ func TestDisasterRecoveryDrProtectionGroupResource_basic(t *testing.T) {
350356
resource.TestCheckResourceAttrSet(resourceName, "log_location.0.namespace"),
351357
resource.TestCheckResourceAttr(resourceName, "members.#", "1"),
352358
resource.TestCheckResourceAttrSet(resourceName, "members.0.member_id"),
353-
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "VOLUME_GROUP"),
359+
resource.TestCheckResourceAttr(resourceName, "members.0.member_type", "OBJECT_STORAGE_BUCKET"),
354360
resource.TestCheckResourceAttrSet(resourceName, "role"),
355361
resource.TestCheckResourceAttrSet(resourceName, "state"),
356362
resource.TestCheckResourceAttrSet(resourceName, "time_created"),

internal/service/disaster_recovery/disaster_recovery_dr_plan_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,10 @@ func (s *DisasterRecoveryDrPlanResourceCrud) mapToUpdateDrPlanGroupDetails(field
671671
result.Id = &tmp
672672
}
673673

674-
if isPauseEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_pause_enabled")); ok {
674+
/*if isPauseEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_pause_enabled")); ok {
675675
tmp := isPauseEnabled.(bool)
676676
result.IsPauseEnabled = &tmp
677-
}
677+
}*/
678678

679679
if steps, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "steps")); ok {
680680
interfaces := steps.([]interface{})

internal/service/disaster_recovery/disaster_recovery_dr_protection_group_resource.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func DisasterRecoveryDrProtectionGroupResource() *schema.Resource {
140140
"FILE_SYSTEM",
141141
"LOAD_BALANCER",
142142
"NETWORK_LOAD_BALANCER",
143+
"OBJECT_STORAGE_BUCKET",
143144
"VOLUME_GROUP",
144145
}, true),
145146
},
@@ -235,6 +236,11 @@ func DisasterRecoveryDrProtectionGroupResource() *schema.Resource {
235236
},
236237
},
237238
},
239+
"bucket": {
240+
Type: schema.TypeString,
241+
Optional: true,
242+
Computed: true,
243+
},
238244
"destination_availability_domain": {
239245
Type: schema.TypeString,
240246
Optional: true,
@@ -375,6 +381,11 @@ func DisasterRecoveryDrProtectionGroupResource() *schema.Resource {
375381
Optional: true,
376382
Computed: true,
377383
},
384+
"namespace": {
385+
Type: schema.TypeString,
386+
Optional: true,
387+
Computed: true,
388+
},
378389
"password_vault_secret_id": {
379390
Type: schema.TypeString,
380391
Optional: true,
@@ -1648,6 +1659,21 @@ func (s *DisasterRecoveryDrProtectionGroupResourceCrud) mapToCreateDrProtectionG
16481659
details.MemberId = &tmp
16491660
}
16501661
baseObject = details
1662+
case strings.ToLower("OBJECT_STORAGE_BUCKET"):
1663+
details := oci_disaster_recovery.CreateDrProtectionGroupMemberObjectStorageBucketDetails{}
1664+
if bucket, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "bucket")); ok {
1665+
tmp := bucket.(string)
1666+
details.BucketName = &tmp
1667+
}
1668+
if namespace, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "namespace")); ok {
1669+
tmp := namespace.(string)
1670+
details.NamespaceName = &tmp
1671+
}
1672+
if memberId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "member_id")); ok {
1673+
tmp := memberId.(string)
1674+
details.MemberId = &tmp
1675+
}
1676+
baseObject = details
16511677
case strings.ToLower("VOLUME_GROUP"):
16521678
details := oci_disaster_recovery.CreateDrProtectionGroupMemberVolumeGroupDetails{}
16531679
if memberId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "member_id")); ok {
@@ -1938,6 +1964,27 @@ func (s *DisasterRecoveryDrProtectionGroupResourceCrud) mapToUpdateDrProtectionG
19381964
}
19391965
}
19401966
baseObject = details
1967+
case strings.ToLower("OBJECT_STORAGE_BUCKET"):
1968+
details := oci_disaster_recovery.UpdateDrProtectionGroupMemberObjectStorageBucketDetails{}
1969+
if bucket, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "bucket")); ok {
1970+
tmp := bucket.(string)
1971+
if tmp != "" {
1972+
details.BucketName = &tmp
1973+
}
1974+
}
1975+
if namespace, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "namespace")); ok {
1976+
tmp := namespace.(string)
1977+
if tmp != "" {
1978+
details.NamespaceName = &tmp
1979+
}
1980+
}
1981+
if memberId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "member_id")); ok {
1982+
tmp := memberId.(string)
1983+
if tmp != "" {
1984+
details.MemberId = &tmp
1985+
}
1986+
}
1987+
baseObject = details
19411988
case strings.ToLower("VOLUME_GROUP"):
19421989
details := oci_disaster_recovery.UpdateDrProtectionGroupMemberVolumeGroupDetails{}
19431990
if memberId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "member_id")); ok {
@@ -2097,6 +2144,20 @@ func DrProtectionGroupMemberToMap(obj oci_disaster_recovery.DrProtectionGroupMem
20972144
result["destination_network_load_balancer_id"] = string(*v.DestinationNetworkLoadBalancerId)
20982145
}
20992146

2147+
if v.MemberId != nil {
2148+
result["member_id"] = string(*v.MemberId)
2149+
}
2150+
case oci_disaster_recovery.DrProtectionGroupMemberObjectStorageBucket:
2151+
result["member_type"] = "OBJECT_STORAGE_BUCKET"
2152+
2153+
if v.BucketName != nil {
2154+
result["bucket"] = string(*v.BucketName)
2155+
}
2156+
2157+
if v.NamespaceName != nil {
2158+
result["namespace"] = string(*v.NamespaceName)
2159+
}
2160+
21002161
if v.MemberId != nil {
21012162
result["member_id"] = string(*v.MemberId)
21022163
}

website/docs/d/disaster_recovery_dr_plan_executions.html.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ data "oci_disaster_recovery_dr_plan_executions" "test_dr_plan_executions" {
2222
#Optional
2323
display_name = var.dr_plan_execution_display_name
2424
dr_plan_execution_id = oci_disaster_recovery_dr_plan_execution.test_dr_plan_execution.id
25-
dr_plan_execution_type = var.dr_plan_execution_dr_plan_execution_type
2625
state = var.dr_plan_execution_state
2726
}
2827
```
@@ -33,7 +32,6 @@ The following arguments are supported:
3332

3433
* `display_name` - (Optional) A filter to return only resources that match the given display name. Example: `MyResourceDisplayName`
3534
* `dr_plan_execution_id` - (Optional) The OCID of the DR plan execution. Example: `ocid1.drplanexecution.oc1..uniqueID`
36-
* `dr_plan_execution_type` - (Optional) The DR plan execution type.
3735
* `dr_protection_group_id` - (Required) The OCID of the DR protection group. Mandatory query param. Example: `ocid1.drprotectiongroup.oc1..uniqueID`
3836
* `state` - (Optional) A filter to return only DR plan executions that match the given lifecycle state.
3937

website/docs/d/disaster_recovery_dr_protection_group.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The following attributes are exported:
5454
* `block_volume_id` - The OCID of the block volume. Example: `ocid1.volume.oc1..uniqueID`
5555
* `mount_details` - The details for mounting or unmounting the file system on a block volume.
5656
* `mount_point` - The physical mount point used for mounting and unmounting the file system on a block volume. Example: `/mnt/yourmountpoint`
57+
* `bucket` - The bucket name inside the object storage namespace. Example: `bucket_name`
5758
* `destination_availability_domain` - The availability domain of the destination mount target. Example: `BBTh:region-AD`
5859
* `destination_capacity_reservation_id` - The OCID of a capacity reservation in the destination region which will be used to launch the compute instance. Example: `ocid1.capacityreservation.oc1..uniqueID`
5960
* `destination_compartment_id` - The OCID of a compartment in the destination region in which the compute instance should be launched. Example: `ocid1.compartment.oc1..uniqueID`
@@ -76,6 +77,7 @@ The following attributes are exported:
7677
* `is_start_stop_enabled` - A flag indicating whether the non-movable compute instance needs to be started and stopped during DR operations.
7778
* `member_id` - The OCID of the member. Example: `ocid1.instance.oc1..uniqueID`
7879
* `member_type` - The type of the member.
80+
* `namespace` - The namespace in object storage (Note - this is usually the tenancy name). Example: `myocitenancy`
7981
* `password_vault_secret_id` - The OCID of the vault secret where the database SYSDBA password is stored. This password is used for performing database DR operations. Example: `ocid1.vaultsecret.oc1..uniqueID`
8082
* `vnic_mapping` - A list of compute instance VNIC mappings.
8183
* `destination_nsg_id_list` - A list of OCIDs of network security groups (NSG) in the destination region which should be assigned to the source VNIC. Example: `[ ocid1.networksecuritygroup.oc1..uniqueID1, ocid1.networksecuritygroup.oc1..uniqueID2 ]`

website/docs/d/disaster_recovery_dr_protection_groups.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The following attributes are exported:
7272
* `block_volume_id` - The OCID of the block volume. Example: `ocid1.volume.oc1..uniqueID`
7373
* `mount_details` - The details for mounting or unmounting the file system on a block volume.
7474
* `mount_point` - The physical mount point used for mounting and unmounting the file system on a block volume. Example: `/mnt/yourmountpoint`
75+
* `bucket` - The bucket name inside the object storage namespace. Example: `bucket_name`
7576
* `destination_availability_domain` - The availability domain of the destination mount target. Example: `BBTh:region-AD`
7677
* `destination_capacity_reservation_id` - The OCID of a capacity reservation in the destination region which will be used to launch the compute instance. Example: `ocid1.capacityreservation.oc1..uniqueID`
7778
* `destination_compartment_id` - The OCID of a compartment in the destination region in which the compute instance should be launched. Example: `ocid1.compartment.oc1..uniqueID`
@@ -94,6 +95,7 @@ The following attributes are exported:
9495
* `is_start_stop_enabled` - A flag indicating whether the non-movable compute instance needs to be started and stopped during DR operations.
9596
* `member_id` - The OCID of the member. Example: `ocid1.instance.oc1..uniqueID`
9697
* `member_type` - The type of the member.
98+
* `namespace` - The namespace in object storage (Note - this is usually the tenancy name). Example: `myocitenancy`
9799
* `password_vault_secret_id` - The OCID of the vault secret where the database SYSDBA password is stored. This password is used for performing database DR operations. Example: `ocid1.vaultsecret.oc1..uniqueID`
98100
* `vnic_mapping` - A list of compute instance VNIC mappings.
99101
* `destination_nsg_id_list` - A list of OCIDs of network security groups (NSG) in the destination region which should be assigned to the source VNIC. Example: `[ ocid1.networksecuritygroup.oc1..uniqueID1, ocid1.networksecuritygroup.oc1..uniqueID2 ]`

0 commit comments

Comments
 (0)