From df168deebeffa8bec4503cac8fb8a026570f75d1 Mon Sep 17 00:00:00 2001 From: Konstantin Tarashchanskiy Date: Tue, 24 Sep 2024 17:18:34 -0400 Subject: [PATCH 1/5] Add basic instructions on using the terraform provider --- README.md | 1 + .../docs/getting-started/connect-database.md | 14 +++++++++++ content/docs/getting-started/connect-dbaas.md | 21 ++++++++++++++++ .../docs/getting-started/create-database.md | 24 +++++++++++++++++++ 4 files changed, 60 insertions(+) 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..14f3ae4 100644 --- a/content/docs/getting-started/connect-database.md +++ b/content/docs/getting-started/connect-database.md @@ -43,6 +43,20 @@ 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 "ca_cert" { + value = nuodbaas_database.db.status.ca_pem +} + +output "db_url" { + value = nuodbaas_database.db.status.sql_endpoint +} +``` + {{< /tab >}} {{< /tabs >}} diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index bc08097..e882da6 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,23 @@ 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. +In production, you will want to specify connection parameters explicitly, but, for prototyping, the provider can find its configuration in the environment varaibles set above. + +```terraform +terraform { + required_providers { + nuodbaas = { + source = "registry.terraform.io/nuodb/nuodbaas" + version = "1.1.0" + } + } +} + +provider "nuodbaas" { + skip_verify = true +} +``` diff --git a/content/docs/getting-started/create-database.md b/content/docs/getting-started/create-database.md index a10280e..4cc12b4 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 >}} From 80085b81cc0494e223b6f2a866339a2feb472205 Mon Sep 17 00:00:00 2001 From: Konstantin Tarashchanskiy Date: Wed, 25 Sep 2024 11:49:19 -0400 Subject: [PATCH 2/5] Addressed reviewer notes --- content/docs/getting-started/connect-database.md | 16 +++++++++++++++- content/docs/getting-started/connect-dbaas.md | 8 +++++--- content/docs/getting-started/create-database.md | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/content/docs/getting-started/connect-database.md b/content/docs/getting-started/connect-database.md index 14f3ae4..b7f36fa 100644 --- a/content/docs/getting-started/connect-database.md +++ b/content/docs/getting-started/connect-database.md @@ -48,12 +48,26 @@ nuosql "demo@${DB_URL}:8443" --user dba --password changeIt --connection-propert {{< 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 + value = "${nuodbaas_database.db.status.sql_endpoint}:443" +} + +output "db_name" { + value = nuodbaas_database.db.name } ``` diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index e882da6..c3b2883 100644 --- a/content/docs/getting-started/connect-dbaas.md +++ b/content/docs/getting-started/connect-dbaas.md @@ -68,20 +68,22 @@ 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. -In production, you will want to specify connection parameters explicitly, but, for prototyping, the provider can find its configuration in the environment varaibles set above. +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 attributes you can define but, if they are not set, the provider can infer a configuration using the environment variables set above. ```terraform terraform { required_providers { nuodbaas = { source = "registry.terraform.io/nuodb/nuodbaas" - version = "1.1.0" + version = "1.2.0" } } } provider "nuodbaas" { + # The provider does not support self signed certificates. + # Disable certificate validation if your Control Plane certificate is not signed by a trusted CA. skip_verify = true } ``` diff --git a/content/docs/getting-started/create-database.md b/content/docs/getting-started/create-database.md index 4cc12b4..b7d661a 100644 --- a/content/docs/getting-started/create-database.md +++ b/content/docs/getting-started/create-database.md @@ -122,5 +122,10 @@ done echo "Database is available" ``` +{{< /tab >}} +{{< tab "terraform" >}} + +Terraform waits until all resources are available before available before reporting a success. + {{< /tab >}} {{< /tabs >}} From 94eb47c3a18db4f38a9a751286910b1dd17f7659 Mon Sep 17 00:00:00 2001 From: Konstantin Tarashchanskiy Date: Wed, 25 Sep 2024 15:15:12 -0400 Subject: [PATCH 3/5] Addressed more reviewer feedback --- content/docs/getting-started/connect-dbaas.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index c3b2883..540d413 100644 --- a/content/docs/getting-started/connect-dbaas.md +++ b/content/docs/getting-started/connect-dbaas.md @@ -69,7 +69,9 @@ 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 attributes you can define but, if they are not set, the provider can infer a configuration using the environment variables set above. +The [provider documentation](https://registry.terraform.io/providers/nuodb/nuodbaas/latest/docs#schema) covers all of the available attributes. +All of the them are optional. +For any that you do not specify, the provider will check the environment variables set above. ```terraform terraform { @@ -82,8 +84,7 @@ terraform { } provider "nuodbaas" { - # The provider does not support self signed certificates. - # Disable certificate validation if your Control Plane certificate is not signed by a trusted CA. + # If your Control Plane certificate is not signed by a trusted CA, disable certificate validation . skip_verify = true } ``` From b6c6480fd187d6fcb61652c0cae6d183739aec47 Mon Sep 17 00:00:00 2001 From: Konstantin Tarashchanskiy Date: Thu, 26 Sep 2024 11:22:06 -0400 Subject: [PATCH 4/5] Caught up to reviewer feedback --- content/docs/getting-started/connect-dbaas.md | 2 +- content/docs/getting-started/create-database.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index 540d413..3717abe 100644 --- a/content/docs/getting-started/connect-dbaas.md +++ b/content/docs/getting-started/connect-dbaas.md @@ -71,7 +71,7 @@ alias curl="curl -s -k -u \"${NUODB_CP_USER}:${NUODB_CP_PASSWORD}\"" 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 the them are optional. -For any that you do not specify, the provider will check the environment variables set above. +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 { diff --git a/content/docs/getting-started/create-database.md b/content/docs/getting-started/create-database.md index b7d661a..a4c920c 100644 --- a/content/docs/getting-started/create-database.md +++ b/content/docs/getting-started/create-database.md @@ -125,7 +125,7 @@ echo "Database is available" {{< /tab >}} {{< tab "terraform" >}} -Terraform waits until all resources are available before available before reporting a success. +Terraform waits until all resources are available before reporting a success. {{< /tab >}} {{< /tabs >}} From b600e2d49fb355ad2a7cff221a48f82dbf8f778a Mon Sep 17 00:00:00 2001 From: Konstantin Tarashchanskiy Date: Thu, 26 Sep 2024 15:45:30 -0400 Subject: [PATCH 5/5] Fixed typo --- content/docs/getting-started/connect-dbaas.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/getting-started/connect-dbaas.md b/content/docs/getting-started/connect-dbaas.md index 3717abe..2e3d4a3 100644 --- a/content/docs/getting-started/connect-dbaas.md +++ b/content/docs/getting-started/connect-dbaas.md @@ -70,7 +70,7 @@ alias curl="curl -s -k -u \"${NUODB_CP_USER}:${NUODB_CP_PASSWORD}\"" 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 the them are optional. +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