Skip to content

Commit

Permalink
feat: added cluster datasource & resource
Browse files Browse the repository at this point in the history
  • Loading branch information
thulasirajkomminar committed Oct 8, 2024
1 parent 66afb71 commit 6e135f1
Show file tree
Hide file tree
Showing 11 changed files with 1,266 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ provider "cratedb" {

### Data Sources

* `cratedb_cluster`
* `cratedb_organization`
* `cratedb_organizations`

### Resources

* `cratedb_cluster`
* `cratedb_organization`

## Developing the Provider
Expand Down
108 changes: 108 additions & 0 deletions docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "cratedb_cluster Data Source - terraform-provider-cratedb"
subcategory: ""
description: |-
To retrieve a cluster.
---

# cratedb_cluster (Data Source)

To retrieve a cluster.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The id of the cluster.

### Read-Only

- `allow_custom_storage` (Boolean) The allow custom storage flag.
- `allow_suspend` (Boolean) The allow suspend flag.
- `backup_schedule` (String) The backup schedule.
- `channel` (String) The channel of the cluster.
- `crate_version` (String) The CrateDB version of the cluster.
- `dc` (Attributes) The DublinCore of the cluster. (see [below for nested schema](#nestedatt--dc))
- `deletion_protected` (Boolean) The deletion protected flag.
- `external_ip` (String) The external IP address.
- `fqdn` (String) The Fully Qualified Domain Name.
- `gc_available` (Boolean) The garbage collection available flag.
- `hardware_specs` (Attributes) The hardware specs of the cluster. (see [below for nested schema](#nestedatt--hardware_specs))
- `health` (Attributes) The health of the cluster. (see [below for nested schema](#nestedatt--health))
- `ip_whitelist` (Attributes List) The IP whitelist of the cluster. (see [below for nested schema](#nestedatt--ip_whitelist))
- `last_async_operation` (Attributes) The last async operation of the cluster. (see [below for nested schema](#nestedatt--last_async_operation))
- `name` (String) The name of the cluster.
- `num_nodes` (Number) The number of nodes in the cluster.
- `origin` (String) The origin of the cluster.
- `password` (String, Sensitive) The password of the cluster.
- `product_name` (String) The product name of the cluster.
- `product_tier` (String) The product tier of the cluster.
- `product_unit` (Number) The product unit of the cluster.
- `project_id` (String) The project id of the cluster.
- `subscription_id` (String) The subscription id of the cluster.
- `suspended` (Boolean) The suspended flag.
- `url` (String) The URL of the cluster.
- `username` (String) The username of the cluster.

<a id="nestedatt--dc"></a>
### Nested Schema for `dc`

Read-Only:

- `created` (String) The created time.
- `modified` (String) The modified time.


<a id="nestedatt--hardware_specs"></a>
### Nested Schema for `hardware_specs`

Read-Only:

- `cpus_per_node` (Number) The cpus per node.
- `disk_size_per_node_bytes` (Number) The disk size per node in bytes.
- `disk_type` (String) The disk type.
- `disks_per_node` (Number) The disks per node.
- `heap_size_bytes` (Number) The heap size in bytes.
- `memory_per_node_bytes` (Number) The memory per node in bytes.


<a id="nestedatt--health"></a>
### Nested Schema for `health`

Read-Only:

- `last_seen` (String) The last seen time.
- `running_operation` (String) The type of the currently running operation. Returns an empty string if there is no operation in progress.
- `status` (String) The health status of the cluster.


<a id="nestedatt--ip_whitelist"></a>
### Nested Schema for `ip_whitelist`

Read-Only:

- `cidr` (String) The CIDR.
- `description` (String) The description.


<a id="nestedatt--last_async_operation"></a>
### Nested Schema for `last_async_operation`

Read-Only:

- `dc` (Attributes) The DublinCore of the cluster. (see [below for nested schema](#nestedatt--last_async_operation--dc))
- `id` (String) The id of the last async operation.
- `status` (String) The status of the last async operation.
- `type` (String) The type of the last async operation.

<a id="nestedatt--last_async_operation--dc"></a>
### Nested Schema for `last_async_operation.dc`

Read-Only:

- `created` (String) The created time.
- `modified` (String) The modified time.
90 changes: 90 additions & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "cratedb_cluster Resource - terraform-provider-cratedb"
subcategory: ""
description: |-
Creates and manages a cluster.
---

# cratedb_cluster (Resource)

Creates and manages a cluster.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `crate_version` (String) The CrateDB version of the cluster.
- `name` (String) The name of the cluster.
- `organization_id` (String) The organization id of the cluster.
- `password` (String, Sensitive) The password of the cluster.
- `product_name` (String) The product name of the cluster.
- `product_tier` (String) The product tier of the cluster.
- `project_id` (String) The project id of the cluster.
- `subscription_id` (String) The subscription id of the cluster.
- `username` (String) The username of the cluster.

### Optional

- `channel` (String) The channel of the cluster. Default is 'stable'.
- `hardware_specs` (Attributes) The hardware specs of the cluster. (see [below for nested schema](#nestedatt--hardware_specs))
- `product_unit` (Number) The product unit of the cluster. Default is `0`.

### Read-Only

- `allow_custom_storage` (Boolean) The allow custom storage flag.
- `allow_suspend` (Boolean) The allow suspend flag.
- `backup_schedule` (String) The backup schedule.
- `dc` (Attributes) The DublinCore of the cluster. (see [below for nested schema](#nestedatt--dc))
- `deletion_protected` (Boolean) The deletion protected flag.
- `external_ip` (String) The external IP address.
- `fqdn` (String) The Fully Qualified Domain Name.
- `gc_available` (Boolean) The garbage collection available flag.
- `health` (Attributes) The health of the cluster. (see [below for nested schema](#nestedatt--health))
- `id` (String) The id of the cluster.
- `ip_whitelist` (Attributes Set) The IP whitelist of the cluster. (see [below for nested schema](#nestedatt--ip_whitelist))
- `num_nodes` (Number) The number of nodes in the cluster.
- `origin` (String) The origin of the cluster.
- `suspended` (Boolean) The suspended flag.
- `url` (String) The URL of the cluster.

<a id="nestedatt--hardware_specs"></a>
### Nested Schema for `hardware_specs`

Optional:

- `cpus_per_node` (Number) The cpus per node.
- `disk_size_per_node_bytes` (Number) The disk size per node in bytes.
- `disk_type` (String) The disk type.
- `disks_per_node` (Number) The disks per node.
- `heap_size_bytes` (Number) The heap size in bytes.
- `memory_per_node_bytes` (Number) The memory per node in bytes.


<a id="nestedatt--dc"></a>
### Nested Schema for `dc`

Read-Only:

- `created` (String) The created time.
- `modified` (String) The modified time.


<a id="nestedatt--health"></a>
### Nested Schema for `health`

Read-Only:

- `status` (String) The health status of the cluster.


<a id="nestedatt--ip_whitelist"></a>
### Nested Schema for `ip_whitelist`

Read-Only:

- `cidr` (String) The CIDR.
- `description` (String) The description.
16 changes: 16 additions & 0 deletions examples/data-sources/cluster/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_providers {
cratedb = {
source = "komminarlabs/cratedb"
}
}
}

data "cratedb_cluster" "default" {
id = "156e7f96-0f6e-4fcc-8940-6e2a52efcee3"
}

output "default_cluster" {
value = data.cratedb_cluster.default
sensitive = true
}
26 changes: 26 additions & 0 deletions examples/resources/cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
cratedb = {
source = "komminarlabs/cratedb"
}
}
}

provider "cratedb" {}

resource "cratedb_cluster" "default" {
organization_id = "667796de-3c06-4503-bc3c-a9adc2a849cc"
crate_version = "5.8.2"
name = "default-cluster"
product_name = "cr4"
product_tier = "default"
project_id = "a99eb2a8-bcf5-418c-866f-67e65a8ada40"
subscription_id = "7c156ae9-9c07-4106-8f42-df93855876c1"
username = "admin"
password = "zyTChd9mfcGBFLb72nJkNeVj6"
}

output "default_cluster" {
value = cratedb_cluster.default.health
sensitive = true
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/komminarlabs/cratedb v0.1.0
github.com/oapi-codegen/runtime v1.1.1
github.com/komminarlabs/cratedb v0.2.0
)

require (
Expand Down Expand Up @@ -52,6 +51,7 @@ require (
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oapi-codegen/runtime v1.1.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gav
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/komminarlabs/cratedb v0.1.0 h1:F0hf7zAaCU2MvF21AJiJIe0DI+98l5QD8xFkCIUpyKA=
github.com/komminarlabs/cratedb v0.1.0/go.mod h1:U6rR2Y2uwDcasah14nfr/yA0iEmHzIJ5pHBq2Sczn2c=
github.com/komminarlabs/cratedb v0.2.0 h1:6OrP2t7R9+EY4jo0lH4/5c3rQ3/zNL9drRndqcmZZYQ=
github.com/komminarlabs/cratedb v0.2.0/go.mod h1:U6rR2Y2uwDcasah14nfr/yA0iEmHzIJ5pHBq2Sczn2c=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
Loading

0 comments on commit 6e135f1

Please sign in to comment.