Skip to content

Commit d9ebc52

Browse files
Terraform Team Automationravinitp
authored andcommitted
Added - Support for OCM - Add Disaster Recovery Feature
1 parent b42de3b commit d9ebc52

File tree

8 files changed

+57
-9
lines changed

8 files changed

+57
-9
lines changed

examples/oracle_content_experience/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ resource "oci_oce_oce_instance" "test_oce_instance" {
5555
instance_license_type = "BYOL"
5656
upgrade_schedule = "UPGRADE_IMMEDIATELY"
5757
waf_primary_domain = "oracle.com"
58+
59+
timeouts {
60+
create = "2h"
61+
update = "60m"
62+
delete = "1h"
63+
}
5864
}
5965

6066
data "oci_oce_oce_instances" "test_oce_instances" {

internal/integrationtest/oce_oce_instance_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ var (
5656
"object_storage_namespace": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_objectstorage_namespace.test_namespace.namespace}`},
5757
"tenancy_id": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_tenancy.test_tenancy.id}`},
5858
"tenancy_name": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_tenancy.test_tenancy.name}`},
59-
"add_on_features": acctest.Representation{RepType: acctest.Optional, Create: []string{`ENABLE_SAUCE`}, Update: []string{`ENABLE_SA`}},
59+
"add_on_features": acctest.Representation{RepType: acctest.Optional, Create: []string{`ENABLE_ADVANCED_HOSTING`, `CROSS_REGION_DR`}, Update: []string{`ENABLE_ADVANCED_HOSTING`, `CROSS_REGION_DR`}},
6060
"defined_tags": acctest.Representation{RepType: acctest.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")}`},
6161
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
62+
"dr_region": acctest.Representation{RepType: acctest.Optional, Create: `us-phoenix-1`, Update: `us-phoenix-1`},
6263
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
6364
"instance_access_type": acctest.Representation{RepType: acctest.Optional, Create: `PUBLIC`},
6465
"instance_license_type": acctest.Representation{RepType: acctest.Optional, Create: `PREMIUM`},
@@ -134,10 +135,11 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
134135
Config: config + compartmentIdVariableStr + adminEmailVariableStr + idcsAccessTokenVariableStr + OceOceInstanceResourceDependencies +
135136
acctest.GenerateResourceFromRepresentationMap("oci_oce_oce_instance", "test_oce_instance", acctest.Optional, acctest.Create, OceOceInstanceRepresentation),
136137
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
137-
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "1"),
138+
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "2"),
138139
resource.TestCheckResourceAttrSet(resourceName, "admin_email"),
139140
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
140141
resource.TestCheckResourceAttr(resourceName, "description", "description"),
142+
resource.TestCheckResourceAttr(resourceName, "dr_region", "us-phoenix-1"),
141143
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
142144
resource.TestCheckResourceAttrSet(resourceName, "guid"),
143145
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -172,10 +174,11 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
172174
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id_for_update}`},
173175
})),
174176
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
175-
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "1"),
177+
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "2"),
176178
resource.TestCheckResourceAttrSet(resourceName, "admin_email"),
177179
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
178180
resource.TestCheckResourceAttr(resourceName, "description", "description"),
181+
resource.TestCheckResourceAttr(resourceName, "dr_region", "us-phoenix-1"),
179182
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
180183
resource.TestCheckResourceAttrSet(resourceName, "guid"),
181184
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -205,10 +208,11 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
205208
Config: config + compartmentIdVariableStr + adminEmailVariableStr + idcsAccessTokenVariableStr + OceOceInstanceResourceDependencies +
206209
acctest.GenerateResourceFromRepresentationMap("oci_oce_oce_instance", "test_oce_instance", acctest.Optional, acctest.Update, OceOceInstanceRepresentation),
207210
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
208-
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "1"),
211+
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "2"),
209212
resource.TestCheckResourceAttrSet(resourceName, "admin_email"),
210213
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
211214
resource.TestCheckResourceAttr(resourceName, "description", "description2"),
215+
resource.TestCheckResourceAttr(resourceName, "dr_region", "us-phoenix-1"),
212216
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
213217
resource.TestCheckResourceAttrSet(resourceName, "guid"),
214218
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -244,10 +248,11 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
244248
resource.TestCheckResourceAttrSet(datasourceName, "tenancy_id"),
245249

246250
resource.TestCheckResourceAttr(datasourceName, "oce_instances.#", "1"),
247-
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.add_on_features.#", "1"),
251+
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.add_on_features.#", "2"),
248252
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.admin_email"),
249253
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.compartment_id", compartmentId),
250254
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.description", "description2"),
255+
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.dr_region", ""),
251256
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.freeform_tags.%", "1"),
252257
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.guid"),
253258
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.id"),
@@ -274,7 +279,7 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
274279
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
275280
resource.TestCheckResourceAttrSet(singularDatasourceName, "oce_instance_id"),
276281

277-
resource.TestCheckResourceAttr(singularDatasourceName, "add_on_features.#", "1"),
282+
resource.TestCheckResourceAttr(singularDatasourceName, "add_on_features.#", "2"),
278283
resource.TestCheckResourceAttrSet(singularDatasourceName, "admin_email"),
279284
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
280285
resource.TestCheckResourceAttr(singularDatasourceName, "description", "description2"),
@@ -301,6 +306,7 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
301306
ImportStateVerify: true,
302307
ImportStateVerifyIgnore: []string{
303308
"idcs_access_token",
309+
"dr_region",
304310
},
305311
ResourceName: resourceName,
306312
},

internal/service/oce/oce_oce_instance_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ func (s *OceOceInstanceDataSourceCrud) SetData() error {
8484
s.D.Set("description", *s.Res.Description)
8585
}
8686

87+
if s.Res.DrRegion != nil {
88+
s.D.Set("dr_region", *s.Res.DrRegion)
89+
}
90+
8791
s.D.Set("freeform_tags", s.Res.FreeformTags)
8892

8993
if s.Res.Guid != nil {

internal/service/oce/oce_oce_instance_resource.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func OceOceInstanceResource() *schema.Resource {
2626
State: schema.ImportStatePassthrough,
2727
},
2828
Timeouts: &schema.ResourceTimeout{
29-
Create: tfresource.GetTimeoutDuration("30m"),
30-
Update: tfresource.GetTimeoutDuration("20m"),
31-
Delete: tfresource.GetTimeoutDuration("20m"),
29+
Create: tfresource.GetTimeoutDuration("2h"),
30+
Update: tfresource.GetTimeoutDuration("60m"),
31+
Delete: tfresource.GetTimeoutDuration("1h"),
3232
},
3333
Create: createOceOceInstance,
3434
Read: readOceOceInstance,
@@ -93,6 +93,11 @@ func OceOceInstanceResource() *schema.Resource {
9393
Optional: true,
9494
Computed: true,
9595
},
96+
"dr_region": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
Computed: true,
100+
},
96101
"freeform_tags": {
97102
Type: schema.TypeMap,
98103
Optional: true,
@@ -277,6 +282,11 @@ func (s *OceOceInstanceResourceCrud) Create() error {
277282
request.Description = &tmp
278283
}
279284

285+
if drRegion, ok := s.D.GetOkExists("dr_region"); ok {
286+
tmp := drRegion.(string)
287+
request.DrRegion = &tmp
288+
}
289+
280290
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
281291
request.FreeformTags = tfresource.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
282292
}
@@ -513,6 +523,11 @@ func (s *OceOceInstanceResourceCrud) Update() error {
513523
request.Description = &tmp
514524
}
515525

526+
if drRegion, ok := s.D.GetOkExists("dr_region"); ok {
527+
tmp := drRegion.(string)
528+
request.DrRegion = &tmp
529+
}
530+
516531
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
517532
request.FreeformTags = tfresource.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
518533
}
@@ -525,6 +540,10 @@ func (s *OceOceInstanceResourceCrud) Update() error {
525540
request.InstanceUsageType = oci_oce.UpdateOceInstanceDetailsInstanceUsageTypeEnum(instanceUsageType.(string))
526541
}
527542

543+
if lifecycleDetails, ok := s.D.GetOkExists("lifecycle_details"); ok {
544+
request.LifecycleDetails = oci_oce.LifecycleDetailsEnum(lifecycleDetails.(string))
545+
}
546+
528547
tmp := s.D.Id()
529548
request.OceInstanceId = &tmp
530549

@@ -583,6 +602,10 @@ func (s *OceOceInstanceResourceCrud) SetData() error {
583602
s.D.Set("description", *s.Res.Description)
584603
}
585604

605+
if s.Res.DrRegion != nil {
606+
s.D.Set("dr_region", *s.Res.DrRegion)
607+
}
608+
586609
s.D.Set("freeform_tags", s.Res.FreeformTags)
587610

588611
if s.Res.Guid != nil {

internal/service/oce/oce_oce_instances_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func (s *OceOceInstancesDataSourceCrud) SetData() error {
133133
oceInstance["description"] = *r.Description
134134
}
135135

136+
if r.DrRegion != nil {
137+
oceInstance["dr_region"] = *r.DrRegion
138+
}
139+
136140
oceInstance["freeform_tags"] = r.FreeformTags
137141

138142
if r.Guid != nil {

website/docs/d/oce_oce_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following attributes are exported:
3737
* `compartment_id` - Compartment Identifier
3838
* `defined_tags` - Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
3939
* `description` - OceInstance description, can be updated
40+
* `dr_region` - disaster recovery paired ragion name
4041
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
4142
* `guid` - Unique GUID identifier that is immutable on creation
4243
* `id` - Unique identifier that is immutable on creation

website/docs/d/oce_oce_instances.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The following attributes are exported:
5252
* `compartment_id` - Compartment Identifier
5353
* `defined_tags` - Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
5454
* `description` - OceInstance description, can be updated
55+
* `dr_region` - disaster recovery paired ragion name
5556
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
5657
* `guid` - Unique GUID identifier that is immutable on creation
5758
* `id` - Unique identifier that is immutable on creation

website/docs/r/oce_oce_instance.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resource "oci_oce_oce_instance" "test_oce_instance" {
3030
add_on_features = var.oce_instance_add_on_features
3131
defined_tags = {"foo-namespace.bar-key"= "value"}
3232
description = var.oce_instance_description
33+
dr_region = var.oce_instance_dr_region
3334
freeform_tags = {"bar-key"= "value"}
3435
instance_access_type = var.oce_instance_instance_access_type
3536
instance_license_type = var.oce_instance_instance_license_type
@@ -48,6 +49,7 @@ The following arguments are supported:
4849
* `compartment_id` - (Required) (Updatable) Compartment Identifier
4950
* `defined_tags` - (Optional) (Updatable) Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
5051
* `description` - (Optional) (Updatable) OceInstance description
52+
* `dr_region` - (Optional) (Updatable) disaster recovery paired ragion name
5153
* `freeform_tags` - (Optional) (Updatable) Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
5254
* `idcs_access_token` - (Required) Identity Cloud Service access token identifying a stripe and service administrator user
5355
* `instance_access_type` - (Optional) Flag indicating whether the instance access is private or public
@@ -73,6 +75,7 @@ The following attributes are exported:
7375
* `compartment_id` - Compartment Identifier
7476
* `defined_tags` - Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
7577
* `description` - OceInstance description, can be updated
78+
* `dr_region` - disaster recovery paired ragion name
7679
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
7780
* `guid` - Unique GUID identifier that is immutable on creation
7881
* `id` - Unique identifier that is immutable on creation

0 commit comments

Comments
 (0)