Skip to content

Commit 8cb42a9

Browse files
committed
Terraform: Implement suggestions by CodeRabbit
1 parent de7503a commit 8cb42a9

File tree

1 file changed

+48
-33
lines changed

1 file changed

+48
-33
lines changed

docs/integrate/terraform/tutorial.md

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33

44
## Introduction
55

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.
88

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+
based on a given parametrization.
1414

1515
## Example
1616

17-
The example below shows a 3 node 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].
17+
This example deploys a 3node cluster across multiple Availability Zones on AWS.
18+
The module currently supports AWS and Azure.
19+
For Azure, see the [README].
2020

2121
## Configuration
2222

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.
23+
First, create a new Terraform configuration file named `main.tf`.
24+
That file references the [crate/cratedb-terraform](https://github.com/crate/cratedb-terraform) repository with the underlying logic of the deployment.
25+
Specify several variables regarding the target environment.
2526

2627

2728
```hcl
2829
module "cratedb-cluster" {
29-
source = "[email protected]:crate/crate-terraform.git//aws"
30+
source = "[email protected]:crate/cratedb-terraform.git//aws"
3031
3132
# Global configuration items for naming/tagging resources
3233
config = {
@@ -38,38 +39,38 @@ module "cratedb-cluster" {
3839
3940
# CrateDB-specific configuration
4041
crate = {
41-
# Java Heap size in GB available to CrateDB
42+
# Java heap size in GB available to CrateDB
4243
heap_size_gb = 2
4344
4445
cluster_name = "crate-cluster"
4546
46-
# The number of nodes the cluster will consist of
47+
# Number of nodes in the cluster
4748
cluster_size = 3
4849
49-
# Enables a self-signed SSL certificate
50+
# Enable a self-signed TLS certificate
5051
ssl_enable = true
5152
}
5253
53-
# The AWS region
54+
# AWS region
5455
region = "eu-central-1"
5556
56-
# The VPC to deploy to
57+
# Target VPC
5758
vpc_id = "vpc-1234567"
5859
59-
# Applicable subnets of the VPC
60+
# Subnets in the VPC
6061
subnet_ids = ["subnet-123456", "subnet-123457"]
6162
62-
# The corresponding availability zones of above subnets
63+
# Availability Zones for the subnets above
6364
availability_zones = ["eu-central-1b", "eu-central-1a"]
6465
65-
# The SSH key pair for EC2 instances
66+
# SSH key pair name for EC2 instances
6667
ssh_keypair = "cratedb-cluster"
6768
6869
# Enable SSH access to EC2 instances
6970
ssh_access = true
7071
}
7172
72-
# Connection information on the newly created cluster
73+
# Connection information for the newly created cluster
7374
output "cratedb" {
7475
value = module.cratedb-cluster
7576
sensitive = true
@@ -78,12 +79,11 @@ output "cratedb" {
7879

7980
## Execution
8081

81-
Once all variables are adjusted, we initialize Terraform by installing needed plugins:
82-
82+
Once you adjust all variables, initialize Terraform by installing the needed plugins.
8383
```bash
8484
$ terraform init
8585
Initializing modules...
86-
Downloading [email protected]:crate/crate-terraform.git for cratedb-cluster...
86+
Downloading [email protected]:crate/cratedb-terraform.git for cratedb-cluster...
8787
- cratedb-cluster in .terraform/modules/cratedb-cluster/aws
8888

8989
Initializing the backend...
@@ -112,7 +112,8 @@ Terraform has been successfully initialized!
112112
[...]
113113
```
114114

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):
115+
Before deploying, optionally print the planned resource creation derived from the
116+
configuration (shortened output below):
116117
```bash
117118
$ terraform plan
118119

@@ -255,7 +256,8 @@ cratedb = <sensitive>
255256
```
256257

257258
## 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:
259+
The `cratedb` output element contains information on the newly created cluster, such as URL and credentials.
260+
Since it contains the admin password, Terraform marks the output as sensitive and does not immediately display it. Use the `terraform output` command to display it:
259261
```bash
260262
$ terraform output cratedb
261263
{
@@ -267,7 +269,13 @@ $ terraform output cratedb
267269

268270
## Teardown
269271

270-
If you no longer need the deployed cluster, a simple `terraform destroy` from the same directory will suffice.
272+
:::{caution}
273+
This tutorial creates billable AWS resources. Destroy the stack when finished
274+
to avoid ongoing costs.
275+
:::
276+
277+
If you no longer need the deployed cluster, a simple `terraform destroy` from
278+
the same directory will suffice.
271279

272280
```bash
273281
$ terraform destroy
@@ -291,16 +299,23 @@ Changes to Outputs:
291299
Destroy complete! Resources: 22 destroyed.
292300
```
293301

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.
302+
Terraform generates and deploys a self‑signed TLS certificate. After adding a
303+
browser exception, CrateDB’s Admin UI prompts for HTTP Basic Auth. Authenticate
304+
with the credentials shown above.
295305

296-
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.
306+
If authentication fails or no prompt appears, wait a few minutes and retry;
307+
VM provisioning and service initialization can take several minutes.
297308

298309
## Final Remarks
299310

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/).
311+
This Terraform configuration targets development or testing and is not
312+
production‑ready (e.g. it does not touch high availability, encryption, backups).
313+
For production, consider using [CrateDB Cloud].
301314

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!
315+
To request enhancements or share feedback, [open an issue on GitHub].
303316

304317

318+
[CrateDB Cloud]: https://crate.io/products/cratedb-cloud/
319+
[open an issue on GitHub]: https://github.com/crate/cratedb-terraform/issues
305320
[README]: https://github.com/crate/cratedb-terraform/blob/main/azure/README.md
306-
[Terraform]: https://www.terraform.io/
321+
[Terraform]: https://developer.hashicorp.com/terraform

0 commit comments

Comments
 (0)