Skip to content

Commit 66aec1c

Browse files
author
Ravi Tandon
committed
Added support for Autonomouse Databases
1 parent 1ce632e commit 66aec1c

27 files changed

+3113
-689
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# oci_database_autonomous_database_backup
2+
3+
## AutonomousDatabaseBackup Resource
4+
5+
### AutonomousDatabaseBackup Reference
6+
7+
The following attributes are exported:
8+
9+
* `autonomous_database_id` - The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the Autonomous Database.
10+
* `compartment_id` - The OCID of the compartment.
11+
* `display_name` - The user-friendly name for the backup. The name does not have to be unique.
12+
* `id` - The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the Autonomous Database backup.
13+
* `is_automatic` - Indicates whether the backup is user-initiated or automatic.
14+
* `lifecycle_details` - Additional information about the current lifecycle state.
15+
* `state` - The current state of the backup.
16+
* `time_ended` - The date and time the backup completed.
17+
* `time_started` - The date and time the backup started.
18+
* `type` - The type of backup.
19+
20+
21+
22+
### Create Operation
23+
Creates a new Autonomous Database backup for the specified database based on the provided request parameters.
24+
25+
26+
The following arguments are supported:
27+
28+
* `autonomous_database_id` - (Required) The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the Autonomous Database backup.
29+
* `display_name` - (Required) The user-friendly name for the backup. The name does not have to be unique.
30+
31+
32+
### Update Operation
33+
34+
35+
The following arguments support updates:
36+
* NO arguments in this resource support updates
37+
38+
** IMPORTANT **
39+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
40+
41+
### Example Usage
42+
43+
```hcl
44+
resource "oci_database_autonomous_database_backup" "test_autonomous_database_backup" {
45+
#Required
46+
autonomous_database_id = "${oci_database_autonomous_database.test_autonomous_database.id}"
47+
display_name = "${var.autonomous_database_backup_display_name}"
48+
}
49+
```
50+
51+
52+
## AutonomousDatabaseBackup Singular DataSource
53+
54+
55+
### Get Operation
56+
Gets information about the specified Autonomous Database backup.
57+
58+
The following arguments are supported:
59+
60+
* `autonomous_database_backup_id` - (Required) The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the Autonomous Database backup.
61+
62+
63+
### Example Usage
64+
65+
```hcl
66+
data "oci_database_autonomous_database_backup" "test_autonomous_database_backup" {
67+
#Required
68+
autonomous_database_backup_id = "${var.autonomous_database_backup_autonomous_database_backup_id}"
69+
}
70+
```
71+
# oci_database_autonomous_database_backups
72+
73+
## AutonomousDatabaseBackup DataSource
74+
75+
Gets a list of autonomous_database_backups.
76+
77+
### List Operation
78+
Gets a list of Autonomous Database backups based on either the `autonomousDatabaseId` or `compartmentId` specified as a query parameter.
79+
80+
The following arguments are supported:
81+
82+
* `autonomous_database_id` - (Optional) The database [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm).
83+
* `compartment_id` - (Optional) The compartment OCID.
84+
* `display_name` - (Optional) A filter to return only resources that match the entire display name given. The match is not case sensitive.
85+
* `state` - (Optional) A filter to return only resources that match the given lifecycle state exactly.
86+
87+
88+
The following attributes are exported:
89+
90+
* `autonomous_database_backups` - The list of autonomous_database_backups.
91+
92+
### Example Usage
93+
94+
```hcl
95+
data "oci_database_autonomous_database_backups" "test_autonomous_database_backups" {
96+
97+
#Optional
98+
autonomous_database_id = "${oci_database_autonomous_database.test_autonomous_database.id}"
99+
compartment_id = "${var.compartment_id}"
100+
display_name = "${var.autonomous_database_backup_display_name}"
101+
state = "${var.autonomous_database_backup_state}"
102+
}
103+
```
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# oci_database_autonomous_database
2+
3+
## AutonomousDatabase Resource
4+
5+
### AutonomousDatabase Reference
6+
7+
The following attributes are exported:
8+
9+
* `compartment_id` - The OCID of the compartment.
10+
* `connection_strings` - The connection string used to connect to the Autonomous Database. The username for the Service Console is ADMIN. Use the password you entered when creating the Autonomous Database for the password value.
11+
* `high` - The High database service provides the highest level of resources to each SQL statement resulting in the highest performance, but supports the fewest number of concurrent SQL statements.
12+
* `low` - The Low database service provides the least level of resources to each SQL statement, but supports the most number of concurrent SQL statements.
13+
* `medium` - The Medium database service provides a lower level of resources to each SQL statement potentially resulting a lower level of performance, but supports more concurrent SQL statements.
14+
* `cpu_core_count` - The number of CPU cores to be made available to the database.
15+
* `data_storage_size_in_tbs` - The quantity of data in the database, in terabytes.
16+
* `db_name` - The database name.
17+
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
18+
* `display_name` - The user-friendly name for the Autonomous Database. The name does not have to be unique.
19+
* `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.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
20+
* `id` - The [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm) of the Autonomous Database.
21+
* `license_model` - The Oracle license model that applies to the Oracle Autonomous Database. The default is BRING_YOUR_OWN_LICENSE.
22+
* `lifecycle_details` - Additional information about the current lifecycle state.
23+
* `service_console_url` - The URL of the Service Console for the Autonomous Database.
24+
* `state` - The current state of the database.
25+
* `time_created` - The date and time the database was created.
26+
27+
28+
29+
### Create Operation
30+
Creates a new Autonomous Database.
31+
32+
33+
The following arguments are supported:
34+
35+
* `admin_password` - (Required) A strong password for Admin. The password must be between 12 and 60 characters long, and must contain at least 1 uppercase, 1 lowercase and 2 numeric characters. It cannot contain the double quote symbol ("). It must be different than the last 4 passwords.
36+
* `compartment_id` - (Required) The Oracle Cloud ID (OCID) of the compartment of the DB system.
37+
* `cpu_core_count` - (Required) The number of CPU Cores to be made available to the database.
38+
* `data_storage_size_in_tbs` - (Required) Size, in terabytes, of the data volume that will be created and attached to the database. This storage can later be scaled up if needed.
39+
* `db_name` - (Required) The database name. The name must begin with an alphabetic character and can contain a maximum of 14 alphanumeric characters. Special characters are not permitted. The database name must be unique in the tenancy.
40+
* `defined_tags` - (Optional) Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
41+
* `display_name` - (Optional) The user-friendly name for the Autonomous Database. The name does not have to be unique.
42+
* `freeform_tags` - (Optional) 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.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
43+
* `license_model` - (Optional) The Oracle license model that applies to the Oracle Autonomous Database. The default is BRING_YOUR_OWN_LICENSE.
44+
45+
46+
### Update Operation
47+
Updates the specified Autonomous Database with a new CPU core count and size.
48+
49+
50+
The following arguments support updates:
51+
* `admin_password` - A strong password for Admin. The password must be between 12 and 60 characters long, and must contain at least 1 uppercase, 1 lowercase and 2 numeric characters. It cannot contain the double quote symbol ("). It must be different than the last 4 passwords.
52+
* `cpu_core_count` - The number of CPU Cores to be made available to the database.
53+
* `data_storage_size_in_tbs` - Size, in terabytes, of the data volume that will be created and attached to the database. This storage can later be scaled up if needed.
54+
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
55+
* `display_name` - The user-friendly name for the Autonomous Database. The name does not have to be unique.
56+
* `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.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
57+
58+
59+
** IMPORTANT **
60+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
61+
62+
### Example Usage
63+
64+
```hcl
65+
resource "oci_database_autonomous_database" "test_autonomous_database" {
66+
#Required
67+
admin_password = "${var.autonomous_database_admin_password}"
68+
compartment_id = "${var.compartment_id}"
69+
cpu_core_count = "${var.autonomous_database_cpu_core_count}"
70+
data_storage_size_in_tbs = "${var.autonomous_database_data_storage_size_in_tbs}"
71+
db_name = "${var.autonomous_database_db_name}"
72+
73+
#Optional
74+
defined_tags = {"Operations.CostCenter"= "42"}
75+
display_name = "${var.autonomous_database_display_name}"
76+
freeform_tags = {"Department"= "Finance"}
77+
license_model = "${var.autonomous_database_license_model}"
78+
}
79+
```
80+
81+
82+
## AutonomousDatabase Singular DataSource
83+
84+
85+
### Get Operation
86+
Gets the details of the specified Autonomous Database.
87+
88+
89+
The following arguments are supported:
90+
91+
* `autonomous_database_id` - (Required) The database [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm).
92+
93+
94+
### Example Usage
95+
96+
```hcl
97+
data "oci_database_autonomous_database" "test_autonomous_database" {
98+
#Required
99+
autonomous_database_id = "${var.autonomous_database_autonomous_database_id}"
100+
}
101+
```
102+
# oci_database_autonomous_databases
103+
104+
## AutonomousDatabase DataSource
105+
106+
Gets a list of autonomous_databases.
107+
108+
### List Operation
109+
Gets a list of Autonomous Databases.
110+
111+
The following arguments are supported:
112+
113+
* `compartment_id` - (Required) The compartment [OCID](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/identifiers.htm).
114+
* `display_name` - (Optional) A filter to return only resources that match the entire display name given. The match is not case sensitive.
115+
* `state` - (Optional) A filter to return only resources that match the given lifecycle state exactly.
116+
117+
118+
The following attributes are exported:
119+
120+
* `autonomous_databases` - The list of autonomous_databases.
121+
122+
### Example Usage
123+
124+
```hcl
125+
data "oci_database_autonomous_databases" "test_autonomous_databases" {
126+
#Required
127+
compartment_id = "${var.compartment_id}"
128+
129+
#Optional
130+
display_name = "${var.autonomous_database_display_name}"
131+
state = "${var.autonomous_database_state}"
132+
}
133+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# If you receive a service error indicating: Failed to create Autonomous Transaction Processing manual backup because Object Storage credentials and tenancy URL are not defined. Refer to:
2+
# https://docs.cloud.oracle.com/iaas/Content/Database/Tasks/atpbackingup.htm#creatingbucket
3+
resource "oci_database_autonomous_database_backup" "test_autonomous_database_backup" {
4+
# Create the backup only if the autonomous database id is provided and has been configured for backups.
5+
count = "${var.autonomous_database_id == "" ? 0 : 1}"
6+
7+
#Required
8+
autonomous_database_id = "${var.autonomous_database_id}"
9+
display_name = "${var.autonomous_database_backup_display_name}"
10+
}
11+
12+
data "oci_database_autonomous_database_backups" "test_autonomous_database_backups" {
13+
14+
#Optional
15+
compartment_id = "${var.compartment_id}"
16+
display_name = "${var.autonomous_database_backup_display_name}"
17+
}
18+
19+
output "autonomous_database_backups" {
20+
value = "${data.oci_database_autonomous_database_backups.test_autonomous_database_backups.autonomous_database_backups}"
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "tenancy_ocid" {}
2+
variable "user_ocid" {}
3+
variable "fingerprint" {}
4+
variable "private_key_path" {}
5+
variable "region" {}
6+
variable "compartment_id" {}
7+
8+
# The autonomous Database should be pre-configured for backups. Refer:
9+
# https://docs.cloud.oracle.com/iaas/Content/Database/Tasks/atpbackingup.htm#creatingbucket
10+
variable "autonomous_database_id" { default = "" }
11+
variable "autonomous_database_backup_display_name" { default = "Monthly Backup" }
12+
13+
provider "oci" {
14+
tenancy_ocid = "${var.tenancy_ocid}"
15+
user_ocid = "${var.user_ocid}"
16+
fingerprint = "${var.fingerprint}"
17+
private_key_path = "${var.private_key_path}"
18+
region = "${var.region}"
19+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
resource "random_string" "autonomous_database_admin_password" {
2+
length = 16
3+
special = true
4+
}
5+
6+
resource "oci_database_autonomous_database" "test_autonomous_database" {
7+
#Required
8+
admin_password = "${random_string.autonomous_database_admin_password.result}"
9+
compartment_id = "${var.compartment_id}"
10+
cpu_core_count = "${var.autonomous_database_cpu_core_count}"
11+
data_storage_size_in_tbs = "${var.autonomous_database_data_storage_size_in_tbs}"
12+
db_name = "${var.autonomous_database_db_name}"
13+
14+
#Optional
15+
display_name = "${var.autonomous_database_display_name}"
16+
freeform_tags = "${var.autonomous_database_freeform_tags}"
17+
license_model = "${var.autonomous_database_license_model}"
18+
}
19+
20+
data "oci_database_autonomous_databases" "test_autonomous_databases" {
21+
#Required
22+
compartment_id = "${var.compartment_id}"
23+
24+
#Optional
25+
display_name = "${var.autonomous_database_display_name}"
26+
}
27+
28+
output "autonomous_database_admin_password" {
29+
value = "${random_string.autonomous_database_admin_password.result}"
30+
}
31+
32+
output "autonomous_databases" {
33+
value = "${data.oci_database_autonomous_databases.test_autonomous_databases.autonomous_databases}"
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
variable "tenancy_ocid" {}
2+
variable "user_ocid" {}
3+
variable "fingerprint" {}
4+
variable "private_key_path" {}
5+
variable "region" {}
6+
variable "compartment_id" {}
7+
8+
variable "autonomous_database_cpu_core_count" { default = 1 }
9+
variable "autonomous_database_data_storage_size_in_tbs" { default = 1 }
10+
variable "autonomous_database_db_name" { default = "adatabasedb1" }
11+
variable "autonomous_database_defined_tags_value" { default = "value" }
12+
variable "autonomous_database_display_name" { default = "example_autonomous_database" }
13+
variable "autonomous_database_freeform_tags" { default = {"Department"= "Finance"} }
14+
variable "autonomous_database_license_model" { default = "LICENSE_INCLUDED" }
15+
16+
provider "oci" {
17+
tenancy_ocid = "${var.tenancy_ocid}"
18+
user_ocid = "${var.user_ocid}"
19+
fingerprint = "${var.fingerprint}"
20+
private_key_path = "${var.private_key_path}"
21+
region = "${var.region}"
22+
}

provider/database_autonomous_data_warehouse_backup_resource.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ func (s *AutonomousDataWarehouseBackupResourceCrud) Create() error {
137137

138138
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "database")
139139

140-
handleDbSimulationFlag(s.Client)
141-
142140
response, err := s.Client.CreateAutonomousDataWarehouseBackup(context.Background(), request)
143141
if err != nil {
144142
return err

provider/database_autonomous_data_warehouse_resource.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ func (s *AutonomousDataWarehouseResourceCrud) Create() error {
253253

254254
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "database")
255255

256-
handleDbSimulationFlag(s.Client)
257-
258256
response, err := s.Client.CreateAutonomousDataWarehouse(context.Background(), request)
259257
if err != nil {
260258
return err

0 commit comments

Comments
 (0)