Skip to content

Commit e7ef971

Browse files
committed
support for updating OCE instance type
1 parent 15f3ef6 commit e7ef971

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 4.18.0 (Unreleased)
2+
3+
### Added
4+
- Support for updating instance type in `oci_oce_oce_instance`
5+
16
## 4.17.0 (March 10, 2021)
27

38
### Added

examples/oracle_content_experience/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "oci_oce_oce_instance" "test_oce_instance" {
4141
compartment_id = var.compartment_ocid
4242
idcs_access_token = var.idcs_access_token
4343
name = "testoceinstance"
44-
object_storage_namespace = var.tenancy_name
44+
object_storage_namespace = data.oci_objectstorage_namespace.test_namespace.namespace
4545
tenancy_id = var.tenancy_ocid
4646
tenancy_name = var.tenancy_name
4747

@@ -79,3 +79,8 @@ output "active_oce_instances" {
7979
output "output_nested_service_data" {
8080
value = jsondecode(data.oci_oce_oce_instance.test_oce_instance.service.dns).A.domain
8181
}
82+
83+
data "oci_objectstorage_namespace" "test_namespace" {
84+
#Optional
85+
compartment_id = var.compartment_ocid
86+
}

oci/oce_oce_instance_resource.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func OceOceInstanceResource() *schema.Resource {
107107
Type: schema.TypeString,
108108
Optional: true,
109109
Computed: true,
110-
ForceNew: true,
111110
},
112111
"upgrade_schedule": {
113112
Type: schema.TypeString,
@@ -457,6 +456,10 @@ func (s *OceOceInstanceResourceCrud) Update() error {
457456
request.InstanceLicenseType = oci_oce.LicenseTypeEnum(instanceLicenseType.(string))
458457
}
459458

459+
if instanceUsageType, ok := s.D.GetOkExists("instance_usage_type"); ok {
460+
request.InstanceUsageType = oci_oce.UpdateOceInstanceDetailsInstanceUsageTypeEnum(instanceUsageType.(string))
461+
}
462+
460463
tmp := s.D.Id()
461464
request.OceInstanceId = &tmp
462465

oci/oce_oce_instance_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ var (
4747
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
4848
"idcs_access_token": Representation{repType: Required, create: `${var.idcs_access_token}`},
4949
"name": Representation{repType: Required, create: instanceName},
50-
"object_storage_namespace": Representation{repType: Required, create: `${data.oci_identity_tenancy.test_tenancy.name}`},
50+
"object_storage_namespace": Representation{repType: Required, create: `${data.oci_objectstorage_namespace.test_namespace.namespace}`},
5151
"tenancy_id": Representation{repType: Required, create: `${data.oci_identity_tenancy.test_tenancy.id}`},
5252
"tenancy_name": Representation{repType: Required, create: `${data.oci_identity_tenancy.test_tenancy.name}`},
5353
"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")}`},
5454
"description": Representation{repType: Optional, create: `description`, update: `description2`},
5555
"freeform_tags": Representation{repType: Optional, create: map[string]string{"bar-key": "value"}, update: map[string]string{"Department": "Accounting"}},
5656
"instance_access_type": Representation{repType: Optional, create: `PUBLIC`},
5757
"instance_license_type": Representation{repType: Optional, create: `NEW`, update: `BYOL`},
58-
"instance_usage_type": Representation{repType: Optional, create: `NONPRIMARY`},
58+
"instance_usage_type": Representation{repType: Optional, create: `NONPRIMARY`, update: `PRIMARY`},
5959
"upgrade_schedule": Representation{repType: Optional, create: `UPGRADE_IMMEDIATELY`},
6060
"waf_primary_domain": Representation{repType: Optional, create: `oracle.com`, update: `java.com`},
6161
}
6262

6363
OceInstanceResourceDependencies = generateDataSourceFromRepresentationMap("oci_identity_tenancy", "test_tenancy", Required, Create, tenancySingularDataSourceRepresentation) +
64+
generateDataSourceFromRepresentationMap("oci_objectstorage_namespace", "test_namespace", Optional, Create, namespaceSingularDataSourceRepresentation) +
6465
DefinedTagsDependencies
6566
)
6667

@@ -216,7 +217,7 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
216217
resource.TestCheckResourceAttrSet(resourceName, "idcs_tenancy"),
217218
resource.TestCheckResourceAttr(resourceName, "instance_access_type", "PUBLIC"),
218219
resource.TestCheckResourceAttr(resourceName, "instance_license_type", "BYOL"),
219-
resource.TestCheckResourceAttr(resourceName, "instance_usage_type", "NONPRIMARY"),
220+
resource.TestCheckResourceAttr(resourceName, "instance_usage_type", "PRIMARY"),
220221
resource.TestCheckResourceAttr(resourceName, "name", instanceName),
221222
resource.TestCheckResourceAttrSet(resourceName, "object_storage_namespace"),
222223
resource.TestCheckResourceAttrSet(resourceName, "tenancy_id"),
@@ -255,7 +256,7 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
255256
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.idcs_tenancy"),
256257
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.instance_access_type", "PUBLIC"),
257258
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.instance_license_type", "BYOL"),
258-
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.instance_usage_type", "NONPRIMARY"),
259+
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.instance_usage_type", "PRIMARY"),
259260
resource.TestCheckResourceAttr(datasourceName, "oce_instances.0.name", instanceName),
260261
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.object_storage_namespace"),
261262
resource.TestCheckResourceAttrSet(datasourceName, "oce_instances.0.state"),
@@ -286,7 +287,7 @@ func TestOceOceInstanceResource_basic(t *testing.T) {
286287
resource.TestCheckResourceAttrSet(singularDatasourceName, "idcs_tenancy"),
287288
resource.TestCheckResourceAttr(singularDatasourceName, "instance_access_type", "PUBLIC"),
288289
resource.TestCheckResourceAttr(singularDatasourceName, "instance_license_type", "BYOL"),
289-
resource.TestCheckResourceAttr(singularDatasourceName, "instance_usage_type", "NONPRIMARY"),
290+
resource.TestCheckResourceAttr(singularDatasourceName, "instance_usage_type", "PRIMARY"),
290291
resource.TestCheckResourceAttr(singularDatasourceName, "name", instanceName),
291292
resource.TestCheckResourceAttrSet(singularDatasourceName, "object_storage_namespace"),
292293
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),

website/docs/r/oce_oce_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The following arguments are supported:
5050
* `idcs_access_token` - (Required) Identity Cloud Service access token identifying a stripe and service administrator user
5151
* `instance_access_type` - (Optional) Flag indicating whether the instance access is private or public
5252
* `instance_license_type` - (Optional) (Updatable) Flag indicating whether the instance license is new cloud or bring your own license
53-
* `instance_usage_type` - (Optional) Instance type based on its usage
53+
* `instance_usage_type` - (Optional) (Updatable) Instance type based on its usage
5454
* `name` - (Required) OceInstance Name
5555
* `object_storage_namespace` - (Required) Object Storage Namespace of Tenancy
5656
* `tenancy_id` - (Required) Tenancy Identifier

0 commit comments

Comments
 (0)