Skip to content

Commit 005a820

Browse files
committed
Add Database VM files.
1 parent 03acbf5 commit 005a820

File tree

5 files changed

+136
-0
lines changed

5 files changed

+136
-0
lines changed

oci/oci_db/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Terraform : Oracle Cloud Infrastructure (OCI) Database VM
2+
3+
Usage description.
4+
5+
* [Terraform : Oracle Cloud Infrastructure (OCI) Database VM](https://oracle-base.com/articles/misc/terraform-oci-database-vm).
6+
7+
Related articles.
8+
9+
* [Terraform : All Articles](https://oracle-base.com/articles/misc/articles-misc#terraform)

oci/oci_db/oci_db.tf

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Variables
2+
variable "compartment_id" { type = string }
3+
variable "db_admin_password" { type = string }
4+
variable "db_name" { type = string }
5+
variable "db_public_keys" { type = list(string) }
6+
variable "db_subnet_id" { type = string }
7+
variable "db_display_name" { type = string }
8+
variable "db_pdb_name" { type = string }
9+
variable "db_hostname" { type = string }
10+
variable "db_host_domain" { type = string }
11+
variable "db_storage_gb" { type = number }
12+
13+
variable "db_workload" {
14+
type = string
15+
default = "OLTP"
16+
}
17+
18+
variable "db_version" {
19+
type = string
20+
default = "21.1.0.0"
21+
}
22+
23+
variable "db_shape" {
24+
type = string
25+
default = "VM.Standard2.1"
26+
}
27+
28+
variable "db_database_edition" {
29+
type = string
30+
default = "ENTERPRISE_EDITION_EXTREME_PERFORMANCE"
31+
}
32+
33+
variable "db_license_model" {
34+
type = string
35+
default = "LICENSE_INCLUDED"
36+
}
37+
38+
variable "db_node_count" {
39+
type = number
40+
default = 1
41+
}
42+
43+
44+
# Resources
45+
data "oci_identity_availability_domains" "ads" {
46+
compartment_id = var.compartment_id
47+
}
48+
49+
resource "oci_database_db_system" "tf_db" {
50+
availability_domain = data.oci_identity_availability_domains.ads.availability_domains[0].name
51+
compartment_id = var.compartment_id
52+
db_home {
53+
database {
54+
admin_password = var.db_admin_password
55+
db_name = var.db_name
56+
db_workload = var.db_workload
57+
pdb_name = var.db_pdb_name
58+
}
59+
db_version = var.db_version
60+
}
61+
hostname = var.db_hostname
62+
shape = var.db_shape
63+
ssh_public_keys = var.db_public_keys
64+
subnet_id = var.db_subnet_id
65+
display_name = var.db_display_name
66+
data_storage_size_in_gb = var.db_storage_gb
67+
database_edition = var.db_database_edition
68+
domain = var.db_host_domain
69+
license_model = var.db_license_model
70+
node_count = var.db_node_count
71+
}
72+
73+
74+
# Outputs
75+
output "db_display_name" {
76+
value = oci_database_db_system.tf_db.display_name
77+
}
78+
79+
output "db_id" {
80+
value = oci_database_db_system.tf_db.id
81+
}
82+
83+
output "db_state" {
84+
value = oci_database_db_system.tf_db.state
85+
}
86+
87+
output "first-availability-domain_name" {
88+
value = data.oci_identity_availability_domains.ads.availability_domains[0].name
89+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Amend with your details.
2+
compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
3+
db_admin_password = "MyStrongPassword123--"
4+
db_host_domain = "obdomain"
5+
db_name = "cdb1"
6+
db_workload = "OLTP"
7+
db_pdb_name = "pdb1"
8+
db_version = "21.1.0.0"
9+
db_hostname = "obtest2"
10+
db_shape = "VM.Standard2.1"
11+
db_public_keys = ["ssh-rsa AAAAB3Nza..."]
12+
db_subnet_id = "ocid1.subnet.oc1.uk-london-1.aaaaaaaa..."
13+
db_display_name = "obtest2"
14+
db_storage_gb = 256

oci/oci_db/oci_provider.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Variables.
2+
variable "tenancy_ocid" { type = string }
3+
variable "user_ocid" { type = string }
4+
variable "private_key_path" { type = string }
5+
variable "fingerprint" { type = string }
6+
variable "region" { type = string }
7+
variable "root_compartment_id" { type = string }
8+
9+
10+
# Resources
11+
provider "oci" {
12+
tenancy_ocid = var.tenancy_ocid
13+
user_ocid = var.user_ocid
14+
private_key_path = var.private_key_path
15+
fingerprint = var.fingerprint
16+
region = var.region
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Amend with your details.
2+
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaa..."
3+
user_ocid = "ocid1.user.oc1..aaaaaaaa..."
4+
private_key_path = "/path-to-my/.oci/my-oci-key.pem"
5+
fingerprint = "a5:68:0f:46:6d:06:43:5a:38:98:74:??:??:??:??:??"
6+
region = "uk-london-1"
7+
root_compartment_id = "ocid1.tenancy.oc1..aaaaaaaa..."

0 commit comments

Comments
 (0)