Skip to content

Commit 7a5f291

Browse files
authored
Add basic instructions on using the terraform provider (#4)
Changed pages are: - Connect to NuoDB Control Plane - Create your first Database - Connect to the Database
1 parent 32d95fc commit 7a5f291

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Please read the [Doks theme](https://getdoks.org/docs/basics/authoring-content/)
6161
To serve a local version of the docs site with your changes, run:
6262

6363
```sh
64+
npm install # Download dependencies
6465
npm run dev
6566
```
6667

content/docs/getting-started/connect-database.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@ nuosql "demo@${DB_URL}:8443" --user dba --password changeIt --connection-propert
4343

4444
[NuoDB client](https://github.com/nuodb/nuodb-client/releases) package v20230228 or later is required to connect to DBaaS database.
4545

46+
{{< /tab >}}
47+
48+
{{< tab "terraform" >}}
49+
50+
```terraform
51+
output "dba_username" {
52+
value = "dba"
53+
}
54+
55+
output "dba_password" {
56+
value = nuodbaas_database.db.dba_password
57+
sensitive = true
58+
# visible with terraform output dba_password
59+
}
60+
61+
output "ca_cert" {
62+
value = nuodbaas_database.db.status.ca_pem
63+
}
64+
65+
output "db_url" {
66+
value = "${nuodbaas_database.db.status.sql_endpoint}:443"
67+
}
68+
69+
output "db_name" {
70+
value = nuodbaas_database.db.name
71+
}
72+
```
73+
4674
{{< /tab >}}
4775
{{< /tabs >}}
4876

content/docs/getting-started/connect-dbaas.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This section describes how to connect to the NuoDB Control Plane REST service vi
2020

2121
- [nuodb-cp](https://github.com/nuodb/nuodb-cp-releases/releases/latest/download/nuodb-cp) or [cURL](https://curl.se/download.html)
2222
- [jq](https://jqlang.github.io/jq/download/)
23+
- (Optional) [terraform](https://developer.hashicorp.com/terraform/downloads)
2324

2425
## Access and Authentication
2526

@@ -64,3 +65,26 @@ Configure `cURL` with DBaaS credentials.
6465
```sh
6566
alias curl="curl -s -k -u \"${NUODB_CP_USER}:${NUODB_CP_PASSWORD}\""
6667
```
68+
69+
### Setting up the Terraform Provider
70+
71+
To use terraform to manage your databases, you will want to use the [`nuodbaas` provider](https://registry.terraform.io/providers/nuodb/nuodbaas).
72+
The [provider documentation](https://registry.terraform.io/providers/nuodb/nuodbaas/latest/docs#schema) covers all of the available attributes.
73+
All of them are optional.
74+
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.
75+
76+
```terraform
77+
terraform {
78+
required_providers {
79+
nuodbaas = {
80+
source = "registry.terraform.io/nuodb/nuodbaas"
81+
version = "1.2.0"
82+
}
83+
}
84+
}
85+
86+
provider "nuodbaas" {
87+
# If your Control Plane certificate is not signed by a trusted CA, disable certificate validation .
88+
skip_verify = true
89+
}
90+
```

content/docs/getting-started/create-database.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ curl -X PUT -H 'Content-Type: application/json' \
4242
-d '{"sla": "dev", "tier": "n0.small"}'
4343
```
4444

45+
{{< /tab >}}
46+
{{< tab "terraform" >}}
47+
48+
```terraform
49+
resource "nuodbaas_project" "proj" {
50+
organization = "acme"
51+
name = "messaging"
52+
sla = "dev"
53+
tier = "n0.small"
54+
}
55+
```
56+
4557
{{< /tab >}}
4658
{{< /tabs >}}
4759

@@ -71,6 +83,18 @@ curl -X PUT -H 'Content-Type: application/json' \
7183
-d '{"dbaPassword": "changeIt"}'
7284
```
7385

86+
{{< /tab >}}
87+
{{< tab "terraform" >}}
88+
89+
```terraform
90+
resource "nuodbaas_database" "db" {
91+
organization = nuodbaas_project.proj.organization
92+
project = nuodbaas_project.proj.name
93+
name = "demo"
94+
dba_password = "changeIt"
95+
}
96+
```
97+
7498
{{< /tab >}}
7599
{{< /tabs >}}
76100

@@ -98,5 +122,10 @@ done
98122
echo "Database is available"
99123
```
100124

125+
{{< /tab >}}
126+
{{< tab "terraform" >}}
127+
128+
Terraform waits until all resources are available before reporting a success.
129+
101130
{{< /tab >}}
102131
{{< /tabs >}}

0 commit comments

Comments
 (0)