Skip to content

Commit

Permalink
Add missing examples
Browse files Browse the repository at this point in the history
* Added missing examples including those for import documentation.
* Generated the resulting docs changes.
  • Loading branch information
fantapop committed Mar 22, 2024
1 parent 260583e commit 3af7e22
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Added any missing examples for data sources, resources and imports.

## [1.4.0] - 2024-03-22

### Added
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ description: |-

Information about the organization associated with the user's API key.

## Example Usage

```terraform
data "cockroach_organization" "prod" {}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
22 changes: 21 additions & 1 deletion docs/resources/allow_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ description: |-

List of IP ranges allowed to access the cluster.


## Example Usage

```terraform
resource "cockroach_allow_list" "vpn" {
name = "vpn"
cidr_ip = "123.123.1.1"
cidr_mask = 32
ui = true
sql = true
cluster_id = cockroach_cluster.staging.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -30,3 +41,12 @@ List of IP ranges allowed to access the cluster.
### Read-Only

- `id` (String) A unique identifier with format `<cluster ID>:<CIDR IP>/<CIDR mask>`.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>:<cidr ip>/<cidr mask>
terraform import cockroach_allow_list.home_office 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:123.123.1.1/32
```
26 changes: 25 additions & 1 deletion docs/resources/client_ca_cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,31 @@ description: |-

Manages client CA certs.


## Example Usage

```terraform
variable "client_certificate" {
type = string
description = "The X509 certificate in PEM format."
// For example in tfvars:
//
//client_certificate = <<-EOT
//-----BEGIN CERTIFICATE-----
//MIIDgTCCAmigAwIBAgIBADANBgkqhkiG9w0BAQ0FADBaMQswCQYDVQQGEwJ1czEL
//MAkGA1UECAwCV0ExDjAMBgNVBAoMBXRlc3QxMQ4wDAYDVQQDDAV0ZXN0MTEOMAwG
//A1UEBwwFdGVzdDExDjAMBgNVBAsMBXRlc3QxMB4XDTIzMDMyMTE5MDczN1oXDTI2
//MDMyMDE5MDczN1owWjELMAkGA1UEBhMCdXMxCzAJBgNVBAgMAldBMQ4wDAYDVQQK
//DAV0ZXN0MTEOMAwGA1UEAwwFdGVzdDExDjAMBgNVBAcMBXRlc3QxMQ4wDAYDVQQL
//...
//-----END CERTIFICATE-----
//EOT
}
resource "cockroach_client_ca_cert" "prod" {
id = cockroach_cluster.prod.id
x509_pem_cert = var.client_certificate
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
32 changes: 31 additions & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,37 @@ description: |-

CockroachDB Cloud cluster. Can be Dedicated or Serverless.


## Example Usage

```terraform
resource "cockroach_cluster" "dedicated" {
name = "cockroach-dedicated"
cloud_provider = "GCP"
dedicated = {
storage_gib = 15
machine_type = "n1-standard-4"
}
regions = [
{
name = "us-central1"
node_count = 1
}
]
}
resource "cockroach_cluster" "serverless" {
name = "cockroach-serverless"
cloud_provider = "GCP"
serverless = {
spend_limit = 1
}
regions = [
{
name = "us-east1"
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
16 changes: 15 additions & 1 deletion docs/resources/cmek.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ description: |-

Customer-managed encryption keys (CMEK) resource for a single cluster.


## Example Usage

```terraform
resource "cockroach_cmek" "dedicated" {
id = cockroach_cluster.dedicated.id
regions = [{
region : "us-central-1"
key : {
auth_principal : "arn:aws:iam::account:role/role-name-with-path"
type : "AWS_KMS"
uri : "arn:aws:kms:us-west-2:111122223333:key/id-of-kms-key"
}
}]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
9 changes: 9 additions & 0 deletions docs/resources/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ resource "cockroach_database" "cockroach" {

- `id` (String) A unique identifier with format `<cluster ID>:<database name>`.
- `table_count` (Number) Number of tables in the database.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>:<database name>
terraform import cockroach_database.my_database 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:mydatabase
```
9 changes: 7 additions & 2 deletions docs/resources/folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ CockroachDB Cloud folder.
## Example Usage

```terraform
resource "cockroach_folder" "cockroach" {
name = "example-folder"
resource "cockroach_folder" "a_team" {
name = "a-team"
parent_id = "root"
}
resource "cockroach_folder" "a_team_dev" {
name = "dev"
parent_id = cockroach_folder.a_team.id
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
16 changes: 16 additions & 0 deletions docs/resources/private_endpoint_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ description: |-

Private Endpoint Connection.

## Example Usage

```terraform
resource "cockroach_private_endpoint_connection" "serverless" {
cluster_id = cockroach_cluster.serverless.id
endpoint_id = "endpoint-id"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -26,3 +33,12 @@ Private Endpoint Connection.
- `id` (String) Used with `terraform import`. Format is "<cluster ID>:<endpoint ID>".
- `region_name` (String) Cloud provider region code associated with this connection.
- `service_id` (String) Server side ID of the Private Endpoint Connection.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>:<connection id>
terraform import cockroach_private_endpoint_connection.resource_name 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:vpce-0c1308d7312217abc
```
9 changes: 9 additions & 0 deletions docs/resources/private_endpoint_services.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ Read-Only:
- `availability_zone_ids` (List of String) AZ IDs users should create their VPCs in to minimize their cost.
- `service_id` (String) Server side ID of the PrivateLink connection.
- `service_name` (String) AWS service name used to create endpoints.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>
terraform import cockroach_private_endpoint_services.resource_name 1f69fdd2-600a-4cfc-a9ba-16995df0d77d
```
9 changes: 9 additions & 0 deletions docs/resources/private_endpoint_trusted_owner.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ resource "cockroach_private_endpoint_trusted_owner" "example" {

- `id` (String) Used with `terraform import`. Format is "<cluster ID>:<owner ID>".
- `owner_id` (String) UUID of the private endpoint trusted owner entry.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>:<owner id>
terraform import cockroach_private_endpoint_trusted_owner.resource_name 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:e50aa10d-1a16-4be8-85e6-4c18221daa49
```
16 changes: 15 additions & 1 deletion docs/resources/sql_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ variable "cluster_id" {
type = string
}
# Remember that even variables marked sensitive will show up
# in the Terraform state file. Always follow best practices
# when managing sensitive info.
# https://developer.hashicorp.com/terraform/tutorials/configuration-language/sensitive-variables#sensitive-values-in-state
variable "sql_user_password" {
type = string
type = string
sensitive = true
}
resource "cockroach_sql_user" "cockroach" {
Expand All @@ -43,3 +48,12 @@ resource "cockroach_sql_user" "cockroach" {
### Read-Only

- `id` (String) A unique identifier with format `<cluster ID>:<SQL user name>`.

## Import

Import is supported using the following syntax:

```shell
# format: <cluster id>:<sql user name>
terraform import cockroach_sql_user.bill 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:bill
```
19 changes: 14 additions & 5 deletions docs/resources/user_role_grants.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ resource "cockroach_user_role_grants" "cockroach" {
},
{
role_name = "CLUSTER_ADMIN",
resource_type = "ORGANIZATION",
resource_id = ""
resource_type = "CLUSTER",
resource_id = cockroach_cluster.prod.id
},
{
role_name = "ORG_MEMBER",
resource_type = "ORGANIZATION",
resource_id = ""
role_name = "FOLDER_ADMIN",
resource_type = "FOLDER",
resource_id = cockroach_folder.dev.id
},
]
}
Expand Down Expand Up @@ -74,3 +74,12 @@ Required:
Optional:

- `resource_id` (String) ID of the resource. Required if the resource_type is 'FOLDER' or 'CLUSTER'. It should be omitted otherwise.

## Import

Import is supported using the following syntax:

```shell
# format: <user id>
terraform import cockroach_user_role_grants.service_account 1f69fdd2-600a-4cfc-a9ba-16995df0d77d
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "cockroach_organization" "prod" {}
2 changes: 2 additions & 0 deletions examples/resources/cockroach_allow_list/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format: <cluster id>:<cidr ip>/<cidr mask>
terraform import cockroach_allow_list.home_office 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:123.123.1.1/32
8 changes: 8 additions & 0 deletions examples/resources/cockroach_allow_list/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "cockroach_allow_list" "vpn" {
name = "vpn"
cidr_ip = "123.123.1.1"
cidr_mask = 32
ui = true
sql = true
cluster_id = cockroach_cluster.staging.id
}
21 changes: 21 additions & 0 deletions examples/resources/cockroach_client_ca_cert/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "client_certificate" {
type = string
description = "The X509 certificate in PEM format."
// For example in tfvars:
//
//client_certificate = <<-EOT
//-----BEGIN CERTIFICATE-----
//MIIDgTCCAmigAwIBAgIBADANBgkqhkiG9w0BAQ0FADBaMQswCQYDVQQGEwJ1czEL
//MAkGA1UECAwCV0ExDjAMBgNVBAoMBXRlc3QxMQ4wDAYDVQQDDAV0ZXN0MTEOMAwG
//A1UEBwwFdGVzdDExDjAMBgNVBAsMBXRlc3QxMB4XDTIzMDMyMTE5MDczN1oXDTI2
//MDMyMDE5MDczN1owWjELMAkGA1UEBhMCdXMxCzAJBgNVBAgMAldBMQ4wDAYDVQQK
//DAV0ZXN0MTEOMAwGA1UEAwwFdGVzdDExDjAMBgNVBAcMBXRlc3QxMQ4wDAYDVQQL
//...
//-----END CERTIFICATE-----
//EOT
}

resource "cockroach_client_ca_cert" "prod" {
id = cockroach_cluster.prod.id
x509_pem_cert = var.client_certificate
}
27 changes: 27 additions & 0 deletions examples/resources/cockroach_cluster/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "cockroach_cluster" "dedicated" {
name = "cockroach-dedicated"
cloud_provider = "GCP"
dedicated = {
storage_gib = 15
machine_type = "n1-standard-4"
}
regions = [
{
name = "us-central1"
node_count = 1
}
]
}

resource "cockroach_cluster" "serverless" {
name = "cockroach-serverless"
cloud_provider = "GCP"
serverless = {
spend_limit = 1
}
regions = [
{
name = "us-east1"
}
]
}
11 changes: 11 additions & 0 deletions examples/resources/cockroach_cmek/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "cockroach_cmek" "dedicated" {
id = cockroach_cluster.dedicated.id
regions = [{
region : "us-central-1"
key : {
auth_principal : "arn:aws:iam::account:role/role-name-with-path"
type : "AWS_KMS"
uri : "arn:aws:kms:us-west-2:111122223333:key/id-of-kms-key"
}
}]
}
2 changes: 2 additions & 0 deletions examples/resources/cockroach_database/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format: <cluster id>:<database name>
terraform import cockroach_database.my_database 1f69fdd2-600a-4cfc-a9ba-16995df0d77d:mydatabase
14 changes: 0 additions & 14 deletions examples/resources/cockroach_dedicated_cluster/resource.tf

This file was deleted.

Loading

0 comments on commit 3af7e22

Please sign in to comment.