diff --git a/README.md b/README.md index 4ca4f1f..0ada272 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Please read the [Doks theme](https://getdoks.org/docs/basics/authoring-content/) To serve a local version of the docs site with your changes, run: ```sh +npm install # Download dependencies npm run dev ``` diff --git a/content/docs/getting-started/connect-database.md b/content/docs/getting-started/connect-database.md index a6a5a5f..b7f36fa 100644 --- a/content/docs/getting-started/connect-database.md +++ b/content/docs/getting-started/connect-database.md @@ -43,6 +43,34 @@ nuosql "demo@${DB_URL}:8443" --user dba --password changeIt --connection-propert [NuoDB client](https://github.com/nuodb/nuodb-client/releases) package v20230228 or later is required to connect to DBaaS database. +{{< /tab >}} + +{{< tab "terraform" >}} + +```terraform +output "dba_username" { + value = "dba" +} + +output "dba_password" { + value = nuodbaas_database.db.dba_password + sensitive = true + # visible with terraform output dba_password +} + +output "ca_cert" { + value = nuodbaas_database.db.status.ca_pem +} + +output "db_url" { + value = "${nuodbaas_database.db.status.sql_endpoint}:443" +} + +output "db_name" { + value = nuodbaas_database.db.name +} +``` + {{< /tab >}} {{< /tabs >}} diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index bc08097..2e3d4a3 100644 --- a/content/docs/getting-started/connect-dbaas.md +++ b/content/docs/getting-started/connect-dbaas.md @@ -20,6 +20,7 @@ This section describes how to connect to the NuoDB Control Plane REST service vi - [nuodb-cp](https://github.com/nuodb/nuodb-cp-releases/releases/latest/download/nuodb-cp) or [cURL](https://curl.se/download.html) - [jq](https://jqlang.github.io/jq/download/) +- (Optional) [terraform](https://developer.hashicorp.com/terraform/downloads) ## Access and Authentication @@ -64,3 +65,26 @@ Configure `cURL` with DBaaS credentials. ```sh alias curl="curl -s -k -u \"${NUODB_CP_USER}:${NUODB_CP_PASSWORD}\"" ``` + +### Setting up the Terraform Provider + +To use terraform to manage your databases, you will want to use the [`nuodbaas` provider](https://registry.terraform.io/providers/nuodb/nuodbaas). +The [provider documentation](https://registry.terraform.io/providers/nuodb/nuodbaas/latest/docs#schema) covers all of the available attributes. +All of them are optional. +For any that you do not specify, the provider will try to infer a value from the environment variables set above before exiting with an error. + +```terraform +terraform { + required_providers { + nuodbaas = { + source = "registry.terraform.io/nuodb/nuodbaas" + version = "1.2.0" + } + } +} + +provider "nuodbaas" { + # If your Control Plane certificate is not signed by a trusted CA, disable certificate validation . + skip_verify = true +} +``` diff --git a/content/docs/getting-started/create-database.md b/content/docs/getting-started/create-database.md index a10280e..a4c920c 100644 --- a/content/docs/getting-started/create-database.md +++ b/content/docs/getting-started/create-database.md @@ -42,6 +42,18 @@ curl -X PUT -H 'Content-Type: application/json' \ -d '{"sla": "dev", "tier": "n0.small"}' ``` +{{< /tab >}} +{{< tab "terraform" >}} + +```terraform +resource "nuodbaas_project" "proj" { + organization = "acme" + name = "messaging" + sla = "dev" + tier = "n0.small" +} +``` + {{< /tab >}} {{< /tabs >}} @@ -71,6 +83,18 @@ curl -X PUT -H 'Content-Type: application/json' \ -d '{"dbaPassword": "changeIt"}' ``` +{{< /tab >}} +{{< tab "terraform" >}} + +```terraform +resource "nuodbaas_database" "db" { + organization = nuodbaas_project.proj.organization + project = nuodbaas_project.proj.name + name = "demo" + dba_password = "changeIt" +} +``` + {{< /tab >}} {{< /tabs >}} @@ -98,5 +122,10 @@ done echo "Database is available" ``` +{{< /tab >}} +{{< tab "terraform" >}} + +Terraform waits until all resources are available before reporting a success. + {{< /tab >}} {{< /tabs >}}