Skip to content

Commit

Permalink
docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
phact committed May 18, 2022
1 parent 53b96e8 commit a29ff21
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 26 deletions.
32 changes: 31 additions & 1 deletion docs/resources/cdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@ description: |-

`astra_cdc` enables cdc for an Astra Serverless table.


## Example Usage

```terraform
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
resource "astra_cdc" "cdc-1" {
depends_on = [ astra_streaming_tenant.streaming_tenant-1 ]
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
database_name = "sai_test"
table = "test"
keyspace = "sai_test"
topic_partitions = 3
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -28,4 +47,15 @@ description: |-

- `id` (String) The ID of this resource.

### Read-Only

- `connector_status` (String) Streaming tenant name
- `data_topic` (String) Streaming tenant name

## Import

Import is supported using the following syntax:

```shell
terraform import astra_cdc.example databaseId/keyspace/table/tenantName
```
80 changes: 80 additions & 0 deletions docs/resources/streaming_sink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "astra_streaming_sink Resource - terraform-provider-astra"
subcategory: ""
description: |-
astra_cdc enables cdc for an Astra Serverless table.
---

# astra_streaming_sink (Resource)

`astra_cdc` enables cdc for an Astra Serverless table.

## Example Usage

```terraform
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest2"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
resource "astra_cdc" "cdc-1" {
depends_on = [ astra_streaming_tenant.streaming_tenant-1 ]
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
database_name = "sai_test"
table = "test"
keyspace = "sai_test"
topic_partitions = 3
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
}
resource "astra_streaming_sink" "streaming_sink-1" {
depends_on = [ astra_streaming_tenant.streaming_tenant-1, astra_cdc.cdc-1 ]
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
topic = astra_cdc.cdc-1.data_topic
region = "useast-4"
cloud_provider = "gcp"
sink_name = "jdbc-clickhouse"
retain_ordering = true
processing_guarantees = "ATLEAST_ONCE"
parallelism = 3
namespace = "default"
sink_configs = jsonencode({
"userName": "clickhouse",
"password": "password",
"jdbcUrl": "jdbc:clickhouse://fake.clickhouse.url:8123/pulsar_clickhouse_jdbc_sink",
"tableName": "pulsar_clickhouse_jdbc_sink"
})
auto_ack = true
}
```

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

### Required

- `auto_ack` (Boolean) auto ack
- `cloud_provider` (String) Cloud provider
- `namespace` (String) Pulsar Namespace
- `parallelism` (Number) Parallelism for Pulsar sink
- `processing_guarantees` (String) "ATLEAST_ONCE""ATMOST_ONCE""EFFECTIVELY_ONCE".
- `region` (String) cloud region
- `retain_ordering` (Boolean) Retain ordering.
- `sink_configs` (String) Sink Configs
- `sink_name` (String) Name of the sink.
- `tenant_name` (String) Streaming tenant name.
- `topic` (String) Streaming tenant topic.

### Optional

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import astra_streaming_sink.example tenant_name/topic
```
18 changes: 17 additions & 1 deletion docs/resources/streaming_tenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ description: |-

`astra_cdc` enables cdc for an Astra Serverless table.


## Example Usage

```terraform
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -27,4 +37,10 @@ description: |-

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
terraform import astra_streaming_tenant.example tenant_name
```
1 change: 1 addition & 0 deletions examples/resources/astra_cdc/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import astra_cdc.example databaseId/keyspace/table/tenantName
16 changes: 16 additions & 0 deletions examples/resources/astra_cdc/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
resource "astra_cdc" "cdc-1" {
depends_on = [astra_streaming_tenant.streaming_tenant-1]
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
database_name = "sai_test"
table = "test"
keyspace = "sai_test"
topic_partitions = 3
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
}
42 changes: 21 additions & 21 deletions examples/resources/astra_private_link_endpoint/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ resource "astra_private_link_endpoint" "example" {
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#adding-credentials
provider "google" {
project = "my-project"
region = "us-east1"
zone = "us-east1-b"
region = "us-east1"
zone = "us-east1-b"
}

resource "astra_private_link" "example" {
Expand All @@ -35,32 +35,32 @@ resource "astra_private_link" "example" {
}

resource "google_compute_network" "example" {
name = "example-network"
auto_create_subnetworks = false
name = "example-network"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "example" {
name = "example-subnetwork"
ip_cidr_range = "10.142.0.0/20"
region = "us-east1"
network = google_compute_network.example.id
name = "example-subnetwork"
ip_cidr_range = "10.142.0.0/20"
region = "us-east1"
network = google_compute_network.example.id
}

resource "google_compute_address" "example" {
name = "endpoint-address"
subnetwork = google_compute_subnetwork.example.id
address_type = "INTERNAL"
region = "us-east1"
name = "endpoint-address"
subnetwork = google_compute_subnetwork.example.id
address_type = "INTERNAL"
region = "us-east1"
}

resource "google_compute_forwarding_rule" "example" {
name = "psc-endpoint"
target = "https://www.googleapis.com/compute/v1/${astra_private_link.example.service_name}"
project = google_compute_network.example.project
ip_address = google_compute_address.example.id
network = google_compute_network.example.id
region = "us-east1"
load_balancing_scheme = ""
name = "psc-endpoint"
target = "https://www.googleapis.com/compute/v1/${astra_private_link.example.service_name}"
project = google_compute_network.example.project
ip_address = google_compute_address.example.id
network = google_compute_network.example.id
region = "us-east1"
load_balancing_scheme = ""
}

# The endpoint ID (PSC Connection ID) is not currently accessible from the google_compute_forwarding_rule terraform object.
Expand Down Expand Up @@ -120,8 +120,8 @@ resource "azurerm_private_endpoint" "example" {
# you will have to destroy and recreate the azurerm_private_endpoint resource in order to
# reconnect and Astra private link endpoint.
resource "astra_private_link_endpoint" "az_private_link_endpoint" {
database_id = "a6bc9c26-e7ce-424f-84c7-0a00afb12588"
datacenter_id = "a6bc9c26-e7ce-424f-84c7-0a00afb12588-1"
database_id = "a6bc9c26-e7ce-424f-84c7-0a00afb12588"
datacenter_id = "a6bc9c26-e7ce-424f-84c7-0a00afb12588-1"
endpoint_id = "${data.azurerm_resource_group.example.id}/providers/Microsoft.Network/privateEndpoints/${azurerm_private_endpoint.example.name}"
}

1 change: 1 addition & 0 deletions examples/resources/astra_streaming_sink/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import astra_streaming_sink.example tenant_name/topic
35 changes: 35 additions & 0 deletions examples/resources/astra_streaming_sink/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest2"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
resource "astra_cdc" "cdc-1" {
depends_on = [astra_streaming_tenant.streaming_tenant-1]
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
database_name = "sai_test"
table = "test"
keyspace = "sai_test"
topic_partitions = 3
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
}
resource "astra_streaming_sink" "streaming_sink-1" {
depends_on = [astra_streaming_tenant.streaming_tenant-1, astra_cdc.cdc-1]
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
topic = astra_cdc.cdc-1.data_topic
region = "useast-4"
cloud_provider = "gcp"
sink_name = "jdbc-clickhouse"
retain_ordering = true
processing_guarantees = "ATLEAST_ONCE"
parallelism = 3
namespace = "default"
sink_configs = jsonencode({
"userName" : "clickhouse",
"password" : "password",
"jdbcUrl" : "jdbc:clickhouse://fake.clickhouse.url:8123/pulsar_clickhouse_jdbc_sink",
"tableName" : "pulsar_clickhouse_jdbc_sink"
})
auto_ack = true
}
1 change: 1 addition & 0 deletions examples/resources/astra_streaming_tenant/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import astra_streaming_tenant.example tenant_name
7 changes: 7 additions & 0 deletions examples/resources/astra_streaming_tenant/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "astra_streaming_tenant" "streaming_tenant-1" {
tenant_name = "terraformtest"
topic = "terraformtest"
region = "useast-4"
cloud_provider = "gcp"
user_email = "seb@datastax.com"
}
6 changes: 3 additions & 3 deletions internal/provider/resource_streaming_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ func setStreamingSinkData(d *schema.ResourceData, tenantName string, topic strin
return nil
}

func parseStreamingSinkID(id string) (string, error) {
func parseStreamingSinkID(id string) (string, string, error) {
idParts := strings.Split(strings.ToLower(id), "/")
if len(idParts) != 1 {
return "", errors.New("invalid role id format: expected tenantID/")
return "", "", errors.New("invalid role id format: expected tenant_name/topic")
}
return idParts[0], nil
return idParts[0], idParts[1], nil
}

0 comments on commit a29ff21

Please sign in to comment.