Skip to content

Commit a29ff21

Browse files
committed
docs and examples
1 parent 53b96e8 commit a29ff21

File tree

11 files changed

+213
-26
lines changed

11 files changed

+213
-26
lines changed

docs/resources/cdc.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,26 @@ description: |-
1010

1111
`astra_cdc` enables cdc for an Astra Serverless table.
1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
resource "astra_streaming_tenant" "streaming_tenant-1" {
17+
tenant_name = "terraformtest"
18+
topic = "terraformtest"
19+
region = "useast-4"
20+
cloud_provider = "gcp"
21+
user_email = "[email protected]"
22+
}
23+
resource "astra_cdc" "cdc-1" {
24+
depends_on = [ astra_streaming_tenant.streaming_tenant-1 ]
25+
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
26+
database_name = "sai_test"
27+
table = "test"
28+
keyspace = "sai_test"
29+
topic_partitions = 3
30+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
31+
}
32+
```
1433

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

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

50+
### Read-Only
51+
52+
- `connector_status` (String) Streaming tenant name
53+
- `data_topic` (String) Streaming tenant name
54+
55+
## Import
56+
57+
Import is supported using the following syntax:
3158

59+
```shell
60+
terraform import astra_cdc.example databaseId/keyspace/table/tenantName
61+
```

docs/resources/streaming_sink.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "astra_streaming_sink Resource - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
astra_cdc enables cdc for an Astra Serverless table.
7+
---
8+
9+
# astra_streaming_sink (Resource)
10+
11+
`astra_cdc` enables cdc for an Astra Serverless table.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "astra_streaming_tenant" "streaming_tenant-1" {
17+
tenant_name = "terraformtest2"
18+
topic = "terraformtest"
19+
region = "useast-4"
20+
cloud_provider = "gcp"
21+
user_email = "[email protected]"
22+
}
23+
resource "astra_cdc" "cdc-1" {
24+
depends_on = [ astra_streaming_tenant.streaming_tenant-1 ]
25+
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
26+
database_name = "sai_test"
27+
table = "test"
28+
keyspace = "sai_test"
29+
topic_partitions = 3
30+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
31+
}
32+
resource "astra_streaming_sink" "streaming_sink-1" {
33+
depends_on = [ astra_streaming_tenant.streaming_tenant-1, astra_cdc.cdc-1 ]
34+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
35+
topic = astra_cdc.cdc-1.data_topic
36+
region = "useast-4"
37+
cloud_provider = "gcp"
38+
sink_name = "jdbc-clickhouse"
39+
retain_ordering = true
40+
processing_guarantees = "ATLEAST_ONCE"
41+
parallelism = 3
42+
namespace = "default"
43+
sink_configs = jsonencode({
44+
"userName": "clickhouse",
45+
"password": "password",
46+
"jdbcUrl": "jdbc:clickhouse://fake.clickhouse.url:8123/pulsar_clickhouse_jdbc_sink",
47+
"tableName": "pulsar_clickhouse_jdbc_sink"
48+
})
49+
auto_ack = true
50+
}
51+
```
52+
53+
<!-- schema generated by tfplugindocs -->
54+
## Schema
55+
56+
### Required
57+
58+
- `auto_ack` (Boolean) auto ack
59+
- `cloud_provider` (String) Cloud provider
60+
- `namespace` (String) Pulsar Namespace
61+
- `parallelism` (Number) Parallelism for Pulsar sink
62+
- `processing_guarantees` (String) "ATLEAST_ONCE""ATMOST_ONCE""EFFECTIVELY_ONCE".
63+
- `region` (String) cloud region
64+
- `retain_ordering` (Boolean) Retain ordering.
65+
- `sink_configs` (String) Sink Configs
66+
- `sink_name` (String) Name of the sink.
67+
- `tenant_name` (String) Streaming tenant name.
68+
- `topic` (String) Streaming tenant topic.
69+
70+
### Optional
71+
72+
- `id` (String) The ID of this resource.
73+
74+
## Import
75+
76+
Import is supported using the following syntax:
77+
78+
```shell
79+
terraform import astra_streaming_sink.example tenant_name/topic
80+
```

docs/resources/streaming_tenant.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ description: |-
1010

1111
`astra_cdc` enables cdc for an Astra Serverless table.
1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
resource "astra_streaming_tenant" "streaming_tenant-1" {
17+
tenant_name = "terraformtest"
18+
topic = "terraformtest"
19+
region = "useast-4"
20+
cloud_provider = "gcp"
21+
user_email = "[email protected]"
22+
}
23+
```
1424

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

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

40+
## Import
41+
42+
Import is supported using the following syntax:
3043

44+
```shell
45+
terraform import astra_streaming_tenant.example tenant_name
46+
```
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import astra_cdc.example databaseId/keyspace/table/tenantName
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "astra_streaming_tenant" "streaming_tenant-1" {
2+
tenant_name = "terraformtest"
3+
topic = "terraformtest"
4+
region = "useast-4"
5+
cloud_provider = "gcp"
6+
user_email = "[email protected]"
7+
}
8+
resource "astra_cdc" "cdc-1" {
9+
depends_on = [astra_streaming_tenant.streaming_tenant-1]
10+
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
11+
database_name = "sai_test"
12+
table = "test"
13+
keyspace = "sai_test"
14+
topic_partitions = 3
15+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
16+
}

examples/resources/astra_private_link_endpoint/resource.tf

+21-21
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ resource "astra_private_link_endpoint" "example" {
2424
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#adding-credentials
2525
provider "google" {
2626
project = "my-project"
27-
region = "us-east1"
28-
zone = "us-east1-b"
27+
region = "us-east1"
28+
zone = "us-east1-b"
2929
}
3030

3131
resource "astra_private_link" "example" {
@@ -35,32 +35,32 @@ resource "astra_private_link" "example" {
3535
}
3636

3737
resource "google_compute_network" "example" {
38-
name = "example-network"
39-
auto_create_subnetworks = false
38+
name = "example-network"
39+
auto_create_subnetworks = false
4040
}
4141

4242
resource "google_compute_subnetwork" "example" {
43-
name = "example-subnetwork"
44-
ip_cidr_range = "10.142.0.0/20"
45-
region = "us-east1"
46-
network = google_compute_network.example.id
43+
name = "example-subnetwork"
44+
ip_cidr_range = "10.142.0.0/20"
45+
region = "us-east1"
46+
network = google_compute_network.example.id
4747
}
4848

4949
resource "google_compute_address" "example" {
50-
name = "endpoint-address"
51-
subnetwork = google_compute_subnetwork.example.id
52-
address_type = "INTERNAL"
53-
region = "us-east1"
50+
name = "endpoint-address"
51+
subnetwork = google_compute_subnetwork.example.id
52+
address_type = "INTERNAL"
53+
region = "us-east1"
5454
}
5555

5656
resource "google_compute_forwarding_rule" "example" {
57-
name = "psc-endpoint"
58-
target = "https://www.googleapis.com/compute/v1/${astra_private_link.example.service_name}"
59-
project = google_compute_network.example.project
60-
ip_address = google_compute_address.example.id
61-
network = google_compute_network.example.id
62-
region = "us-east1"
63-
load_balancing_scheme = ""
57+
name = "psc-endpoint"
58+
target = "https://www.googleapis.com/compute/v1/${astra_private_link.example.service_name}"
59+
project = google_compute_network.example.project
60+
ip_address = google_compute_address.example.id
61+
network = google_compute_network.example.id
62+
region = "us-east1"
63+
load_balancing_scheme = ""
6464
}
6565

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import astra_streaming_sink.example tenant_name/topic
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
resource "astra_streaming_tenant" "streaming_tenant-1" {
2+
tenant_name = "terraformtest2"
3+
topic = "terraformtest"
4+
region = "useast-4"
5+
cloud_provider = "gcp"
6+
user_email = "[email protected]"
7+
}
8+
resource "astra_cdc" "cdc-1" {
9+
depends_on = [astra_streaming_tenant.streaming_tenant-1]
10+
database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
11+
database_name = "sai_test"
12+
table = "test"
13+
keyspace = "sai_test"
14+
topic_partitions = 3
15+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
16+
}
17+
resource "astra_streaming_sink" "streaming_sink-1" {
18+
depends_on = [astra_streaming_tenant.streaming_tenant-1, astra_cdc.cdc-1]
19+
tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
20+
topic = astra_cdc.cdc-1.data_topic
21+
region = "useast-4"
22+
cloud_provider = "gcp"
23+
sink_name = "jdbc-clickhouse"
24+
retain_ordering = true
25+
processing_guarantees = "ATLEAST_ONCE"
26+
parallelism = 3
27+
namespace = "default"
28+
sink_configs = jsonencode({
29+
"userName" : "clickhouse",
30+
"password" : "password",
31+
"jdbcUrl" : "jdbc:clickhouse://fake.clickhouse.url:8123/pulsar_clickhouse_jdbc_sink",
32+
"tableName" : "pulsar_clickhouse_jdbc_sink"
33+
})
34+
auto_ack = true
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import astra_streaming_tenant.example tenant_name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "astra_streaming_tenant" "streaming_tenant-1" {
2+
tenant_name = "terraformtest"
3+
topic = "terraformtest"
4+
region = "useast-4"
5+
cloud_provider = "gcp"
6+
user_email = "[email protected]"
7+
}

internal/provider/resource_streaming_sink.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ func setStreamingSinkData(d *schema.ResourceData, tenantName string, topic strin
456456
return nil
457457
}
458458

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

0 commit comments

Comments
 (0)