Skip to content

Commit

Permalink
Add basic instructions on using the terraform provider (#4)
Browse files Browse the repository at this point in the history
Changed pages are:
- Connect to NuoDB Control Plane
- Create your first Database
- Connect to the Database
  • Loading branch information
kontaras authored Sep 27, 2024
1 parent 32d95fc commit 7a5f291
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
28 changes: 28 additions & 0 deletions content/docs/getting-started/connect-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}

Expand Down
24 changes: 24 additions & 0 deletions content/docs/getting-started/connect-dbaas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
```
29 changes: 29 additions & 0 deletions content/docs/getting-started/create-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}

Expand Down Expand Up @@ -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 >}}

Expand Down Expand Up @@ -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 >}}

0 comments on commit 7a5f291

Please sign in to comment.