Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2020 Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

# Asset Template

Creating a module documentation

### link:https://terraform-docs.io[Terradoc]

Create a asciidoc file for a module
`terraform-docs asciidoc document --sort=false ./ > ./readme.adoc`

Create a md file for a module
`terraform-docs markdown --sort=false ./ > ./readme.md`

### link:https://asciidoctor.org[Asciidoctor]

transfer an adoc file into docbook xml format
`asciidoc -b docbook index.adoc`

### link:https://pandoc.org[Pandoc]

transfer docbook xml format into md format
`iconv -t utf-8 index.xml | pandoc -f docbook -t markdown_strict --wrap=none | iconv -f utf-8 > index.md`
22 changes: 22 additions & 0 deletions backup.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2020 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

/*
resource "oci_database_autonomous_database_backup" "database" {
#Required
autonomous_database_id = oci_database_autonomous_database.autonomous_database.id
display_name = var.autonomous_database_backup_display_name
}

resource "oci_database_autonomous_database" "database_from_backup" {
#Required
admin_password = random_string.autonomous_database_admin_password.result
compartment_id = var.compartment_ocid
cpu_core_count = "1"
data_storage_size_in_tbs = "1"
db_name = "adbdb2"
clone_type = "FULL"
source = "BACKUP_FROM_ID"
autonomous_database_backup_id = oci_database_autonomous_database_backup.autonomous_database_backup.id
}
*/
36 changes: 36 additions & 0 deletions config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2020 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

// --- terraform provider ---
terraform {
required_providers {
oci = {
source = "hashicorp/oci"
}
}
}

data "oci_identity_compartments" "database" {
compartment_id = var.tenancy.id
access_level = "ANY"
compartment_id_in_subtree = true
name = try(var.database.compartment, var.resident.name)
state = "ACTIVE"
}
data "oci_database_autonomous_databases" "database" {
compartment_id = data.oci_identity_compartments.database.compartments[0].id
}

locals {
adb_count = var.input.create ? 1 : 0
}


// Define the wait state for the data requests
resource "null_resource" "previous" {}

// This resource will destroy (potentially immediately) after null_resource.next
resource "time_sleep" "wait" {
depends_on = [null_resource.previous]
create_duration = "2m"
}
61 changes: 61 additions & 0 deletions input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2020 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

variable "input" {
type = object({
create = bool
})
description = "Input for database module"
}

variable "tenancy" {
type = object({
id = string,
class = number,
buckets = string,
region = map(string)
})
description = "Tenancy Configuration"
}

variable "assets" {
type = object({
resident = any
encryption = any
})
description = "Retrieve asset identifier"
}

variable "resident" {
type = object({
owner = string,
name = string,
label = string,
stage = number,
region = map(string)
compartments = map(number),
repository = string,
groups = map(string),
policies = map(any),
notifications = map(any),
tag_namespaces = map(number),
tags = any
})
description = "Service Configuration"
}

variable "database" {
type = object({
name = string,
cores = number,
storage = number,
type = string,
compartment = string,
stage = number,
display_name = string,
version = string,
password = string,
license = string
})
description = "Database Configuration"
}
23 changes: 23 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2020 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

output "database_ids" {
description = "A list of automous databases created by the database module"
value = { for adb in data.oci_database_autonomous_databases.database.autonomous_databases : adb.display_name => adb.id }
}

output "service_console_url" {
value = oci_database_autonomous_database.database[0].service_console_url
}

output "connection_strings" {
value = oci_database_autonomous_database.database[0].connection_strings[0].all_connection_strings
}

output "connection_urls" {
value = oci_database_autonomous_database.database[0].connection_urls[0]
}

output "password" {
value = var.assets.encryption.passwords[var.database.password]
}
18 changes: 18 additions & 0 deletions resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2020 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

resource "oci_database_autonomous_database" "database" {
compartment_id = data.oci_identity_compartments.database.compartments[0].id
count = local.adb_count
cpu_core_count = var.database.cores
data_storage_size_in_tbs = var.database.storage
db_name = var.database.name
admin_password = var.assets.encryption.passwords[var.database.password]
db_version = var.database.version
display_name = var.database.display_name
db_workload = var.database.type
is_free_tier = var.tenancy.class == "FREE_TIER" ? "true" : "false"
license_model = var.database.license
defined_tags = var.assets.resident.defined_tags
freeform_tags = var.assets.resident.freeform_tags
}