Skip to content

Commit 9e783af

Browse files
committed
Support for ATP-S autoscaling
1 parent 7b55635 commit 9e783af

11 files changed

+119
-35
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.28.0 (Unreleased)
2+
3+
### Added
4+
- Support for ATP-S autoscaling
5+
16
## 3.27.0 (May 29, 2019)
27

38
### Added

examples/database/adb/autonomous_data_warehouse.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ resource "oci_database_autonomous_database" "autonomous_data_warehouse" {
1212
#Required
1313
admin_password = "${random_string.autonomous_data_warehouse_admin_password.result}"
1414
compartment_id = "${var.compartment_ocid}"
15-
cpu_core_count = "${var.autonomous_database_cpu_core_count}"
16-
data_storage_size_in_tbs = "${var.autonomous_database_data_storage_size_in_tbs}"
17-
db_name = "${var.autonomous_data_warehouse_db_name}"
15+
cpu_core_count = "1"
16+
data_storage_size_in_tbs = "1"
17+
db_name = "adbdw1"
1818

1919
#Optional
2020
db_workload = "${var.autonomous_data_warehouse_db_workload}"
21-
display_name = "${var.autonomous_data_warehouse_display_name}"
21+
display_name = "example_autonomous_data_warehouse"
2222
freeform_tags = "${var.autonomous_database_freeform_tags}"
2323
license_model = "${var.autonomous_database_license_model}"
2424
}

examples/database/adb/autonomous_database.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ resource "oci_database_autonomous_database" "autonomous_database" {
1212
#Required
1313
admin_password = "${random_string.autonomous_database_admin_password.result}"
1414
compartment_id = "${var.compartment_ocid}"
15-
cpu_core_count = "${var.autonomous_database_cpu_core_count}"
16-
data_storage_size_in_tbs = "${var.autonomous_database_data_storage_size_in_tbs}"
17-
db_name = "${var.autonomous_database_db_name}"
15+
cpu_core_count = "1"
16+
data_storage_size_in_tbs = "1"
17+
db_name = "adbdb1"
1818

1919
#Optional
20-
db_workload = "${var.autonomous_database_db_workload}"
21-
display_name = "${var.autonomous_database_display_name}"
22-
freeform_tags = "${var.autonomous_database_freeform_tags}"
23-
license_model = "${var.autonomous_database_license_model}"
20+
db_workload = "${var.autonomous_database_db_workload}"
21+
display_name = "example_autonomous_database"
22+
freeform_tags = "${var.autonomous_database_freeform_tags}"
23+
is_auto_scaling_enabled = "true"
24+
license_model = "${var.autonomous_database_license_model}"
2425
}
2526

2627
data "oci_database_autonomous_databases" "autonomous_databases" {

examples/database/adb/variables.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@ variable "private_key_path" {}
77
variable "region" {}
88
variable "compartment_ocid" {}
99

10-
variable "autonomous_database_cpu_core_count" {
11-
default = 1
12-
}
13-
14-
variable "autonomous_database_data_storage_size_in_tbs" {
15-
default = 1
16-
}
17-
18-
variable "autonomous_database_db_name" {
19-
default = "adbdb1"
20-
}
21-
22-
variable "autonomous_data_warehouse_db_name" {
23-
default = "adbdw1"
24-
}
25-
2610
variable "autonomous_database_db_workload" {
2711
default = "OLTP"
2812
}
@@ -35,14 +19,6 @@ variable "autonomous_database_defined_tags_value" {
3519
default = "value"
3620
}
3721

38-
variable "autonomous_database_display_name" {
39-
default = "example_autonomous_database"
40-
}
41-
42-
variable "autonomous_data_warehouse_display_name" {
43-
default = "example_autonomous_data_warehouse"
44-
}
45-
4622
variable "autonomous_database_freeform_tags" {
4723
default = {
4824
"Department" = "Finance"

oci/database_autonomous_database_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func (s *DatabaseAutonomousDatabaseDataSourceCrud) SetData() error {
100100

101101
s.D.Set("freeform_tags", s.Res.FreeformTags)
102102

103+
if s.Res.IsAutoScalingEnabled != nil {
104+
s.D.Set("is_auto_scaling_enabled", *s.Res.IsAutoScalingEnabled)
105+
}
106+
103107
s.D.Set("license_model", s.Res.LicenseModel)
104108

105109
if s.Res.LifecycleDetails != nil {

oci/database_autonomous_database_resource.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
8080
Computed: true,
8181
Elem: schema.TypeString,
8282
},
83+
"is_auto_scaling_enabled": {
84+
Type: schema.TypeBool,
85+
Optional: true,
86+
Computed: true,
87+
},
8388
"license_model": {
8489
Type: schema.TypeString,
8590
Optional: true,
@@ -331,6 +336,11 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) Update() error {
331336
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
332337
}
333338

339+
if isAutoScalingEnabled, ok := s.D.GetOkExists("is_auto_scaling_enabled"); ok && s.D.HasChange("is_auto_scaling_enabled") {
340+
tmp := isAutoScalingEnabled.(bool)
341+
request.IsAutoScalingEnabled = &tmp
342+
}
343+
334344
if licenseModel, ok := s.D.GetOkExists("license_model"); ok && s.D.HasChange("license_model") {
335345
request.LicenseModel = oci_database.UpdateAutonomousDatabaseDetailsLicenseModelEnum(licenseModel.(string))
336346
}
@@ -409,6 +419,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) SetData() error {
409419

410420
s.D.Set("freeform_tags", s.Res.FreeformTags)
411421

422+
if s.Res.IsAutoScalingEnabled != nil {
423+
s.D.Set("is_auto_scaling_enabled", *s.Res.IsAutoScalingEnabled)
424+
}
425+
412426
s.D.Set("license_model", s.Res.LicenseModel)
413427

414428
if s.Res.LifecycleDetails != nil {
@@ -510,6 +524,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
510524
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
511525
details.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
512526
}
527+
if isAutoScalingEnabled, ok := s.D.GetOkExists("is_auto_scaling_enabled"); ok {
528+
tmp := isAutoScalingEnabled.(bool)
529+
details.IsAutoScalingEnabled = &tmp
530+
}
513531
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
514532
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
515533
}
@@ -553,6 +571,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
553571
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
554572
details.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
555573
}
574+
if isAutoScalingEnabled, ok := s.D.GetOkExists("is_auto_scaling_enabled"); ok {
575+
tmp := isAutoScalingEnabled.(bool)
576+
details.IsAutoScalingEnabled = &tmp
577+
}
556578
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
557579
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
558580
}

oci/database_autonomous_database_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var (
5252
"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")}`},
5353
"display_name": Representation{repType: Optional, create: `example_autonomous_database`, update: `displayName2`},
5454
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
55+
"is_auto_scaling_enabled": Representation{repType: Optional, create: `false`},
5556
"license_model": Representation{repType: Optional, create: `LICENSE_INCLUDED`},
5657
}
5758

@@ -128,6 +129,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
128129
resource.TestCheckResourceAttr(resourceName, "display_name", "example_autonomous_database"),
129130
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
130131
resource.TestCheckResourceAttrSet(resourceName, "id"),
132+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
131133
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
132134
resource.TestCheckResourceAttrSet(resourceName, "state"),
133135

@@ -153,6 +155,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
153155
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
154156
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
155157
resource.TestCheckResourceAttrSet(resourceName, "id"),
158+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
156159
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
157160
resource.TestCheckResourceAttrSet(resourceName, "state"),
158161

@@ -181,6 +184,36 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
181184
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
182185
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
183186
resource.TestCheckResourceAttrSet(resourceName, "id"),
187+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
188+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
189+
resource.TestCheckResourceAttrSet(resourceName, "state"),
190+
resource.TestCheckResourceAttr(resourceName, "whitelisted_ips.#", "2"),
191+
192+
func(s *terraform.State) (err error) {
193+
resId2, err = fromInstanceState(s, resourceName, "id")
194+
if resId != resId2 {
195+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
196+
}
197+
return err
198+
},
199+
),
200+
},
201+
// verify autoscaling
202+
{
203+
Config: config + compartmentIdVariableStr + AutonomousDatabaseResourceDependencies +
204+
generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update, representationCopyWithNewProperties(autonomousDatabaseRepresentation, map[string]interface{}{"is_auto_scaling_enabled": Representation{repType: Optional, update: `true`}})),
205+
Check: resource.ComposeAggregateTestCheckFunc(
206+
resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"),
207+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
208+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
209+
resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"),
210+
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
211+
resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"),
212+
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
213+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
214+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
215+
resource.TestCheckResourceAttrSet(resourceName, "id"),
216+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "true"),
184217
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
185218
resource.TestCheckResourceAttrSet(resourceName, "state"),
186219
resource.TestCheckResourceAttr(resourceName, "whitelisted_ips.#", "2"),
@@ -218,6 +251,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
218251
resource.TestCheckResourceAttr(datasourceName, "autonomous_databases.0.display_name", "displayName2"),
219252
resource.TestCheckResourceAttr(datasourceName, "autonomous_databases.0.freeform_tags.%", "1"),
220253
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_databases.0.id"),
254+
resource.TestCheckResourceAttr(datasourceName, "autonomous_databases.0.is_auto_scaling_enabled", "false"),
221255
resource.TestCheckResourceAttr(datasourceName, "autonomous_databases.0.license_model", "LICENSE_INCLUDED"),
222256
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_databases.0.state"),
223257
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_databases.0.time_created"),
@@ -244,6 +278,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
244278
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName2"),
245279
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
246280
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
281+
resource.TestCheckResourceAttr(singularDatasourceName, "is_auto_scaling_enabled", "false"),
247282
resource.TestCheckResourceAttr(singularDatasourceName, "license_model", "LICENSE_INCLUDED"),
248283
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
249284
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
@@ -329,6 +364,38 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
329364
),
330365
},
331366

367+
// verify autoscaling with DW workload
368+
{
369+
Config: config + compartmentIdVariableStr + AutonomousDatabaseResourceDependencies +
370+
generateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", Optional, Update,
371+
getMultipleUpdatedRepresenationCopy([]string{"db_workload", "is_auto_scaling_enabled"},
372+
[]interface{}{Representation{repType: Optional, create: "DW"},
373+
Representation{repType: Optional, update: `true`}}, autonomousDatabaseRepresentation)),
374+
Check: resource.ComposeAggregateTestCheckFunc(
375+
resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"),
376+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
377+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
378+
resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"),
379+
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
380+
resource.TestCheckResourceAttr(resourceName, "db_workload", "DW"),
381+
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
382+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
383+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
384+
resource.TestCheckResourceAttrSet(resourceName, "id"),
385+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "true"),
386+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
387+
resource.TestCheckResourceAttrSet(resourceName, "state"),
388+
389+
func(s *terraform.State) (err error) {
390+
resId2, err = fromInstanceState(s, resourceName, "id")
391+
if resId != resId2 {
392+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
393+
}
394+
return err
395+
},
396+
),
397+
},
398+
332399
// remove any previously created resources
333400
{
334401
Config: config + compartmentIdVariableStr + AutonomousDatabaseResourceDependencies,

oci/database_autonomous_databases_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ func (s *DatabaseAutonomousDatabasesDataSourceCrud) SetData() error {
152152
autonomousDatabase["id"] = *r.Id
153153
}
154154

155+
if r.IsAutoScalingEnabled != nil {
156+
autonomousDatabase["is_auto_scaling_enabled"] = *r.IsAutoScalingEnabled
157+
}
158+
155159
autonomousDatabase["license_model"] = r.LicenseModel
156160

157161
if r.LifecycleDetails != nil {

website/docs/d/database_autonomous_database.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following attributes are exported:
4747
* `display_name` - The user-friendly name for the Autonomous Database. The name does not have to be unique.
4848
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
4949
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Autonomous Database.
50+
* `is_auto_scaling_enabled` - Indicates if auto scaling is enabled for the Autonomous Database CPU core count.
5051
* `license_model` - The Oracle license model that applies to the Oracle Autonomous Database. The default is BRING_YOUR_OWN_LICENSE.
5152
* `lifecycle_details` - Information about the current lifecycle state.
5253
* `service_console_url` - The URL of the Service Console for the Autonomous Database.

website/docs/d/database_autonomous_databases.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The following attributes are exported:
6161
* `display_name` - The user-friendly name for the Autonomous Database. The name does not have to be unique.
6262
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
6363
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Autonomous Database.
64+
* `is_auto_scaling_enabled` - Indicates if auto scaling is enabled for the Autonomous Database CPU core count.
6465
* `license_model` - The Oracle license model that applies to the Oracle Autonomous Database. The default is BRING_YOUR_OWN_LICENSE.
6566
* `lifecycle_details` - Information about the current lifecycle state.
6667
* `service_console_url` - The URL of the Service Console for the Autonomous Database.

0 commit comments

Comments
 (0)