Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AV-87721] GSI release documentation for Terraform V1.4.0 #244

Open
wants to merge 74 commits into
base: AV-87721_release_documentation_for_V1.4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
1357aae
api structs
l0n3star Sep 12, 2024
ff757ad
terraform structs
l0n3star Sep 12, 2024
5b9b6ad
query index resource
l0n3star Sep 12, 2024
dd7fddd
implement ResourceWithValidateConfig
l0n3star Sep 18, 2024
7748ae0
refactor query index resource
l0n3star Sep 19, 2024
1e32130
query index datasource
l0n3star Sep 24, 2024
3874e44
query index monitor datasource
l0n3star Sep 25, 2024
db5f07e
cleanup
l0n3star Sep 25, 2024
7b54667
fix list indexes
l0n3star Sep 25, 2024
b5239ff
fix import
l0n3star Sep 25, 2024
5f43574
documentation
l0n3star Sep 25, 2024
7d7a78a
documentation
l0n3star Sep 25, 2024
6b32b38
add . to end of comments
l0n3star Sep 25, 2024
9589750
handle build in progress
l0n3star Oct 14, 2024
b6ca35d
update example
l0n3star Oct 15, 2024
582b6cc
type assertion must be checked
l0n3star Oct 15, 2024
ba0cd42
update terraform.template.tfvars in example
l0n3star Oct 15, 2024
d9d93ec
update variables in example
l0n3star Oct 15, 2024
408546e
use ValueString() for Where field
l0n3star Oct 21, 2024
1292df8
set state once
l0n3star Oct 21, 2024
26d86fa
remove resource from state file if externally deleted
l0n3star Oct 21, 2024
70a5e6d
imports
l0n3star Oct 22, 2024
e26e82e
poll index
l0n3star Oct 23, 2024
cff6e19
refactor query_index_monitor
l0n3star Oct 24, 2024
605985c
fix typo
l0n3star Oct 24, 2024
83f5524
fix index build validation
l0n3star Oct 25, 2024
158b509
watch indexes
l0n3star Oct 26, 2024
a2673d0
remove listStringValues
l0n3star Oct 26, 2024
eb801d4
do not poll on build in progress error
l0n3star Oct 28, 2024
6a7597f
mark resource with buid in progress error as tainted
l0n3star Oct 28, 2024
bfd6e46
use WatchIndexes for gsi monitor
l0n3star Oct 29, 2024
b989623
fix error handling
l0n3star Oct 29, 2024
50c83bb
fix with clause
l0n3star Oct 29, 2024
cce0627
set useStateForUnknown for computed attributes
l0n3star Oct 30, 2024
d7c217d
use set for build_indexes
l0n3star Oct 30, 2024
3eaf05f
refactor poll deferred indexes
l0n3star Nov 1, 2024
8e54e25
fix WatchIndexes
l0n3star Nov 5, 2024
dcae6d3
update examples
l0n3star Nov 5, 2024
218633a
don't save to state file on delete
l0n3star Nov 6, 2024
9f65692
in example don't list on destroy
l0n3star Nov 6, 2024
5c6efe5
add comments
l0n3star Nov 7, 2024
1d1f308
make tffmt
l0n3star Nov 7, 2024
155c53a
golangci-lint run
l0n3star Nov 7, 2024
6620159
rate limiter
l0n3star Nov 12, 2024
4d35b08
update comments
l0n3star Nov 13, 2024
d3a728a
Merge branch 'main' of https://github.com/couchbasecloud/terraform-pr…
l0n3star Nov 13, 2024
dbc7247
go mod tidy
l0n3star Nov 13, 2024
7e0c8e6
correct spelling
l0n3star Nov 13, 2024
e67bc4a
update EnsureIndexesAreCreated
l0n3star Nov 13, 2024
62cc8b3
remove for_each for gsi monitor in example
l0n3star Nov 14, 2024
9b7fc34
use WatchIndexes instead of EnsureIndexesAreCreated
l0n3star Nov 14, 2024
affbefc
rate limit all gsi api calls
l0n3star Nov 15, 2024
cf0fff7
update example
l0n3star Nov 16, 2024
c34b2ef
adding gsi index acceptance test
SaicharanCB Nov 20, 2024
0801ce1
merge gsi
a-atri Nov 21, 2024
7ae6b22
Release documentation for GSI Index
a-atri Nov 21, 2024
52af5fe
Release documetation for GSI
a-atri Nov 21, 2024
0375a68
Updating docs based on the changes requested by the docs team
a-atri Nov 25, 2024
89e6ce7
fix panic on read
l0n3star Nov 21, 2024
2f2142b
change schema defaults
l0n3star Nov 25, 2024
0ff4723
set num_replica in state file
l0n3star Nov 26, 2024
9746681
manually refresh state on concurrent index creation requests
l0n3star Nov 27, 2024
7847f35
adding acceptance tests
SaicharanCB Nov 29, 2024
d157a88
update comment
l0n3star Nov 27, 2024
83afb62
update README
l0n3star Nov 27, 2024
58e61ac
return warning for concurrent index creation
l0n3star Dec 2, 2024
9eedb3d
index status
l0n3star Dec 3, 2024
9a13a63
comment out undefined function in acc test
l0n3star Dec 3, 2024
37d5e2b
update non deferred example
l0n3star Dec 3, 2024
adeda6d
update deferred example
l0n3star Dec 3, 2024
337148a
make tffmt
l0n3star Dec 3, 2024
7bfc147
merged updated gsi branch into documentation branch
a-atri Dec 5, 2024
7847c0c
Updating docs based on the changes requested by the docs team
a-atri Nov 25, 2024
31ebb9c
Updating the description based on the feedback received from the docs…
a-atri Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/data-sources/query_index_monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "couchbase-capella_query_index_monitor Data Source - terraform-provider-couchbase-capella"
subcategory: ""
description: |-

---

# couchbase-capella_query_index_monitor (Data Source)





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

### Required

- `bucket_name` (String)
- `cluster_id` (String)
- `indexes` (Set of String)
- `organization_id` (String)
- `project_id` (String)

### Optional

- `collection_name` (String)
- `scope_name` (String)
40 changes: 40 additions & 0 deletions docs/data-sources/query_indexes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "couchbase-capella_query_indexes Data Source - terraform-provider-couchbase-capella"
subcategory: ""
description: |-

---

# couchbase-capella_query_indexes (Data Source)





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

### Required

- `bucket_name` (String)
- `cluster_id` (String)
- `organization_id` (String)
- `project_id` (String)

### Optional

- `collection_name` (String)
- `scope_name` (String)

### Read-Only

- `data` (Attributes Set) (see [below for nested schema](#nestedatt--data))

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

Read-Only:

- `definition` (String)
- `index_name` (String)
93 changes: 91 additions & 2 deletions docs/guides/1.4.0-upgrade-guide.md
a-atri marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New features in 1.4.0
## New Features
* Enable Flush Bucket [`couchbase-capella_flush`](https://registry.terraform.io/providers/couchbasecloud/couchbase-capella/latest/docs/resources/flush)
* Enable Azure Network Peer [`couchbase-capella_network_peer`](https://registry.terraform.io/providers/couchbasecloud/couchbase-capella/latest/docs/resources/network_peer)
* GSI [`couchbase-capella_query_indexes`](https://registry.terraform.io/providers/couchbasecloud/couchbase-capella/latest/docs/resources/query_indexes)


## Flush Bucket
Expand Down Expand Up @@ -112,8 +113,96 @@ resource "couchbase-capella_network_peer" "new_network_peer" {
```
For more information, see the [network peer examples](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/tree/main/examples/network_peer).

## GSI
To create a deferred index, use the `query_indexes` resource as follows:
```
locals {
index_template = templatefile("${path.module}/indexes3.json", {
organization_id = var.organization_id
project_id = var.project_id
cluster_id = var.cluster_id
})

decoded_template = jsondecode(local.index_template)
index_names = [for idx, details in local.decoded_template.resource["couchbase-capella_indexes"] : details.index_name]
}
```
```
resource "couchbase-capella_query_indexes" "new_indexes" {
for_each = jsondecode(local.index_template).resource["couchbase-capella_indexes"]
organization_id = each.value.organization_id
project_id = each.value.project_id
cluster_id = each.value.cluster_id
bucket_name = each.value.bucket_name
scope_name = each.value.scope_name
collection_name = each.value.collection_name
index_name = each.value.index_name
index_keys = each.value.index_keys
with = {
defer_build = each.value.with.defer_build
}
}
```
```
resource "couchbase-capella_query_indexes" "build_idx" {
organization_id = var.organization_id
project_id = var.project_id
cluster_id = var.cluster_id

bucket_name = var.bucket_name
scope_name = var.scope_name
collection_name = var.collection_name

build_indexes = local.index_names
}
```
```
output "mon_idx1" {
value = data.couchbase-capella_query_index_monitor.mon
}
```
```
data "couchbase-capella_query_index_monitor" "mon" {
organization_id = var.organization_id
project_id = var.project_id
cluster_id = var.cluster_id
bucket_name = var.bucket_name
scope_name = var.scope_name
collection_name = var.collection_name
indexes = local.index_names

depends_on = [couchbase-capella_query_indexes.build_idx]
}
```
For more information, see the [query_indexes](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/tree/main/examples/gsi/deferred).

To create a non-deferred index, use the `query_indexs` resource as follows:
```
locals {
index_template = templatefile("${path.module}/indexes.json", {
organization_id = var.organization_id
project_id = var.project_id
cluster_id = var.cluster_id
})
}
```
```
resource "couchbase-capella_query_indexes" "new_indexes" {
for_each = jsondecode(local.index_template).resource["couchbase-capella_indexes"]
organization_id = each.value.organization_id
project_id = each.value.project_id
cluster_id = each.value.cluster_id
bucket_name = each.value.bucket_name
scope_name = each.value.scope_name
collection_name = each.value.collection_name
index_name = each.value.index_name
index_keys = each.value.index_keys
}
```
Comment on lines +181 to +201
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should encourage customers to only create 1 non-deferred index. Testing shows creating multiple non-deferred indexes is problematic. So please change to :

resource "couchbase-capella_query_indexes" "idx" {
  organization_id = var.organization_id
  project_id      = var.project_id
  cluster_id      = var.cluster_id

  bucket_name     = var.bucket_name
  scope_name      = var.scope_name
  collection_name = var.collection_name

  index_name = var.index_name
  index_keys = var.index_keys
}

output "idx" {
  value = couchbase-capella_query_indexes.idx
}

For more information, see the [query_indexes](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/tree/main/examples/gsi/non_deferred).

### Helpful Links

- [Getting Started with the Terraform Provider](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/blob/master/examples/getting_started)
- [Capella V4 Management APIs](https://docs.couchbase.com/cloud/management-api-reference/index.html)
- [Specific Examples in the examples folder](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/blob/master/examples)
- [Capella Management API v4.0](https://docs.couchbase.com/cloud/management-api-reference/index.html)
- [See Specific Examples](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/blob/master/examples)
4 changes: 4 additions & 0 deletions docs/index.md
a-atri marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,7 @@ To get started, see the [Provider Example Configs](https://github.com/couchbasec

Manage Flush Bucket

* [Manage GSI](https://github.com/couchbasecloud/terraform-provider-couchbase-capella/tree/main/examples/gsi)

Manage GSI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l0n3star Tagging in reference to discussion on slack thread. Tagging here so we don't miss

Copy link
Contributor

@l0n3star l0n3star Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-atri @simon-dew

please note I made significant updates (yesterday) to the non-deferred and deferred examples for several reasons. first, had to include output showing index status. this is priority for priya and request came in 2 days ago. second, updated the examples to give better guidance to users. in particular, we should encourages users to create 1 non-deferred index. third, priya wanted to use different bucket/scope/collection names to make it more user friendly.

please reference updated examples below:
https://github.com/couchbasecloud/terraform-provider-couchbase-capella/tree/7147d366f6fffee59b4772e16bf910e33dc9e680/examples/gsi


44 changes: 44 additions & 0 deletions docs/resources/query_indexes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "couchbase-capella_query_indexes Resource - terraform-provider-couchbase-capella"
subcategory: ""
description: |-

---

# couchbase-capella_query_indexes (Resource)





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

### Required

- `bucket_name` (String)
- `cluster_id` (String)
- `organization_id` (String)
- `project_id` (String)

### Optional

- `build_indexes` (Set of String)
- `collection_name` (String)
- `index_keys` (List of String)
- `index_name` (String)
- `is_primary` (Boolean)
- `partition_by` (List of String)
- `scope_name` (String)
- `where` (String)
- `with` (Attributes) (see [below for nested schema](#nestedatt--with))

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

Optional:

- `defer_build` (Boolean)
- `num_partition` (Number)
- `num_replica` (Number)
1 change: 1 addition & 0 deletions examples/getting_started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ In this demo, we will perform the following operations:
15. Create a new audit log settings.
16. Enable private endpoint service on the cluster.
17. Create a new network peer.
18. Create an index.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of index? GSI and deferred or non-deferred?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's partitioned index (non-deferred).


## Pre-Requisites:

Expand Down
19 changes: 19 additions & 0 deletions examples/getting_started/gsi.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "couchbase-capella_query_indexes" "idx" {
organization_id = var.organization_id
project_id = couchbase-capella_project.new_project.id
cluster_id = couchbase-capella_cluster.new_cluster.id

bucket_name = couchbase-capella_bucket.new_bucket.name
scope_name = couchbase-capella_scope.new_scope.scope_name
collection_name = couchbase-capella_collection.new_collection.collection_name

index_name = var.index_name
index_keys = var.index_keys
partition_by = var.partition_by

with = {
defer_build = var.with.defer_build
num_replica = var.with.num_replica
num_partition = var.with.num_partition
}
}
14 changes: 14 additions & 0 deletions examples/getting_started/terraform.template.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,18 @@ aws_config = {
vpc_id = "vpc-141f0fffff141aa00"
region = "us-east-1"
cidr = "10.0.0.0/16"
}

bucket_name = "test"
scope_name = "test"
collection_name = "test"

index_name = "idx_pe9"
index_keys = ["sourceairport", "destinationairport", "stops", "airline", "id", "ARRAY_COUNT(schedule)"]
partition_by = ["sourceairport", "destinationairport"]

with = {
defer_build = false
num_replica = 1
num_partition = 8
}
22 changes: 22 additions & 0 deletions examples/getting_started/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,25 @@ variable "aws_config" {
region = optional(string)
})
}

variable "index_name" {
description = "index Name"
}

variable "index_keys" {
description = "index keys"
}

variable "partition_by" {
description = "partition_by"
}

variable "with" {
description = "WITH clause"

type = object({
defer_build = bool
num_replica = number
num_partition = number
})
}
Loading
Loading