You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrate/terraform/tutorial.md
+94-48Lines changed: 94 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,30 +3,49 @@
3
3
4
4
## Introduction
5
5
6
-
CrateDB already has a wide variety of deployment options, ranging from
7
-
{ref}`docker-compose` to {ref}`cloud setups <install-cloud>` on AWS and Azure.
6
+
CrateDB offers multiple deployment options, from {ref}`docker-compose` to
7
+
{ref}`cloud setups <install-cloud>` on AWS and Azure.
8
8
9
-
To make cloud setups more manageable and predictable, we today add another
10
-
option using [Terraform], an infrastructure-as-code tool.
11
-
Terraform eliminates the need to create resources manually via the cloud console.
12
-
Instead, it is based on a configuration language describing resources based
13
-
on a given parametrization.
9
+
To make cloud setups more manageable and predictable, this guide presents
10
+
another option using [Terraform], an infrastructure-as-code tool.
11
+
Terraform eliminates manual console steps to create resources.
12
+
Instead, Terraform uses a configuration language that describes resources
13
+
with parameters.
14
+
15
+
## Prerequisites
16
+
17
+
- Terraform CLI >= 1.5
18
+
- An AWS account with credentials configured (AWS SSO/profile or env vars)
19
+
and a default region or the provider block shown below
20
+
- Existing VPC and subnet IDs in the chosen region (and their AZ mapping)
21
+
- An EC2 key pair name to use for SSH
22
+
- jq installed (used to pretty‑print JSON output)
14
23
15
24
## Example
16
25
17
-
The example below shows a 3node cluster across several availability zones on AWS.
18
-
Currently, AWS and Azure are supported as target platforms.
19
-
The setup for Azure is very similar, please see the [README].
26
+
This example deploys a 3‑node cluster across multiple Availability Zones on AWS.
27
+
The module currently supports AWS and Azure.
28
+
For Azure, see the [README].
20
29
21
30
## Configuration
22
31
23
-
First, we create a new Terraform configuration file named `main.tf`.
24
-
That file references the [crate/crate-terraform](https://github.com/crate/crate-terraform) repository with the underlying logic of the deployment. Several variables need to be specified regarding the target environment.
25
-
32
+
First, create a Terraform configuration file named `main.tf`.
33
+
Reference the [cratedb-terraform] module, which contains the deployment logic.
34
+
Then, specify variables for the target environment.
@@ -112,7 +132,8 @@ Terraform has been successfully initialized!
112
132
[...]
113
133
```
114
134
115
-
Before deploying anything to the cloud, we can optionally print the planned resource creation that Terraform derived from the configuration (the output below is shortened):
135
+
Before deploying, optionally print the planned resource creation derived from the
136
+
configuration (shortened output below):
116
137
```bash
117
138
$ terraform plan
118
139
@@ -122,7 +143,7 @@ Terraform used the selected providers to generate the following execution plan.
122
143
123
144
Terraform will perform the following actions:
124
145
125
-
# module.cratedb-cluster.aws_instance.cratedb_node[0] will be created
146
+
# module.cratedb_cluster.aws_instance.cratedb_node[0] will be created
126
147
+ resource "aws_instance""cratedb_node" {
127
148
+ ami = "ami-0afc0414aefc9eaa7"
128
149
+ arn = (known after apply)
@@ -140,7 +161,7 @@ Terraform will perform the following actions:
140
161
+ instance_type = "t3.xlarge"
141
162
+ ipv6_address_count = (known after apply)
142
163
+ ipv6_addresses = (known after apply)
143
-
+ key_name = "cratedb-cluster"
164
+
+ key_name = "cratedb_cluster"
144
165
+ monitoring = (known after apply)
145
166
+ outpost_arn = (known after apply)
146
167
+ password_data = (known after apply)
@@ -226,7 +247,7 @@ Terraform will perform the following actions:
226
247
}
227
248
}
228
249
229
-
# module.cratedb-cluster.aws_instance.cratedb_node[1] will be created
250
+
# module.cratedb_cluster.aws_instance.cratedb_node[1] will be created
230
251
+ resource "aws_instance""cratedb_node" {
231
252
[...]
232
253
}
@@ -254,20 +275,33 @@ Outputs:
254
275
cratedb = <sensitive>
255
276
```
256
277
257
-
## Connecting to CrateDB
258
-
The `cratedb` output element contains information on the newly created cluster, such as URL and credentials. Since it contains the admin password, the output is marked as sensitive and not immediately shown by Terraform. It can be made visible via the `terraform output` command:
278
+
## Connect to CrateDB
279
+
280
+
The `cratedb` output element contains the connection details (URL and
281
+
credentials). Because it’s marked sensitive, human‑readable output is
282
+
redacted. Use the `terraform output` command to display it, adding
283
+
`-json` to print the full value and pipe it to `jq` (ensure `jq` is
If you no longer need the deployed cluster, a simple `terraform destroy` from the same directory will suffice.
298
+
:::{caution}
299
+
This tutorial creates billable AWS resources. Destroy the stack when finished
300
+
to avoid ongoing costs.
301
+
:::
302
+
303
+
If you no longer need the deployed cluster, a simple `terraform destroy` from
304
+
the same directory will suffice.
271
305
272
306
```bash
273
307
$ terraform destroy
@@ -276,7 +310,7 @@ Terraform used the selected providers to generate the following execution plan.
276
310
277
311
Terraform will perform the following actions:
278
312
279
-
# module.cratedb-cluster.aws_instance.cratedb_node[0] will be destroyed
313
+
# module.cratedb_cluster.aws_instance.cratedb_node[0] will be destroyed
280
314
- resource "aws_instance""cratedb_node" {
281
315
[...]
282
316
} -> null
@@ -291,16 +325,28 @@ Changes to Outputs:
291
325
Destroy complete! Resources: 22 destroyed.
292
326
```
293
327
294
-
For optimal security, a self-signed SSL certificate was automatically generated and deployed. After adding an exception in your browser to accept the certificate, the HTTP Basic Auth dialog of CrateDB’s Admin UI will show. Authenticate with the credentials retrieved from above.
328
+
Terraform generates and deploys a self‑signed TLS certificate. After adding a
If the credentials are rejected, or no authentication prompt appears, please wait for a couple of minutes and try again. Provisioning the virtual machines might not be complete yet and can take several minutes.
332
+
If authentication fails or no prompt appears:
333
+
- Wait a few minutes; provisioning can take time.
334
+
- Verify the load balancer is healthy and targets are in service.
335
+
- Confirm the security group allows inbound HTTPS from your IP.
336
+
- Ensure DNS/URL matches the ALB listener port (4200).
297
337
298
338
## Final Remarks
299
339
300
-
Please note that (as of now) the provided Terraform configuration is meant for development or testing purposes and doesn’t fulfill all requirements of a production-ready setup (i.e. regarding high availability, encryption, or backups). For production-ready setups, please consider [CrateDB Cloud](https://crate.io/products/cratedb-cloud/).
340
+
This Terraform configuration targets development or testing and is not
341
+
production‑ready (e.g., it does not configure high availability, disk encryption,
342
+
automated backups, or managed TLS certificates).
343
+
For production, consider using [CrateDB Cloud].
301
344
302
-
If you have any feedback or requests to extend the configuration, please feel free to [open an issue on GitHub](https://github.com/crate/crate-terraform/issues) or let us know in this thread!
345
+
To request enhancements or share feedback, [open an issue on GitHub].
0 commit comments