Skip to content

Commit b783d58

Browse files
authored
streaming_sink: deprecate cloud_provider and region fields (#457)
1 parent 114b804 commit b783d58

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

docs/resources/streaming_sink.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ resource "astra_streaming_sink" "streaming_sink" {
7777
### Required
7878

7979
- `auto_ack` (Boolean) auto ack
80-
- `cloud_provider` (String) Cloud provider
8180
- `namespace` (String) Pulsar Namespace
8281
- `parallelism` (Number) Parallelism for Pulsar sink
8382
- `processing_guarantees` (String) "ATLEAST_ONCE""ATMOST_ONCE""EFFECTIVELY_ONCE".
84-
- `region` (String) cloud region
8583
- `retain_ordering` (Boolean) Retain ordering.
8684
- `sink_configs` (String) Sink Configs
8785
- `sink_name` (String) Name of the sink.
@@ -91,8 +89,10 @@ resource "astra_streaming_sink" "streaming_sink" {
9189
### Optional
9290

9391
- `archive` (String) Name of the sink archive type to use. Defaults to the value of sink_name. Must be formatted as a URL, e.g. 'builtin://jdbc-clickhouse
92+
- `cloud_provider` (String, Deprecated) Cloud provider
9493
- `deletion_protection` (Boolean) Whether or not to allow Terraform to destroy this streaming sink. Unless this field is set to false in Terraform state, a `terraform destroy` or `terraform apply` command that deletes the instance will fail. Defaults to `true`.
9594
- `pulsar_cluster` (String) Name of the pulsar cluster in which to create the sink. If left blank, the name will be inferred from thecloud provider and region
95+
- `region` (String, Deprecated) cloud region
9696

9797
### Read-Only
9898

internal/provider/resource_streaming_sink.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ func resourceStreamingSink() *schema.Resource {
5454
},
5555
"region": {
5656
Description: "cloud region",
57+
Deprecated: "use `pulsar_cluster` instead",
5758
Type: schema.TypeString,
58-
Required: true,
59+
Optional: true,
5960
ForceNew: true,
6061
ValidateFunc: validation.StringMatch(regexp.MustCompile("^.{2,}"), "name must be atleast 2 characters"),
6162
},
6263
"cloud_provider": {
6364
Description: "Cloud provider",
65+
Deprecated: "use `pulsar_cluster` instead",
6466
Type: schema.TypeString,
65-
Required: true,
67+
Optional: true,
6668
ForceNew: true,
6769
ValidateFunc: validation.StringMatch(regexp.MustCompile("^.{2,}"), "name must be atleast 2 characters"),
6870
},
@@ -144,12 +146,17 @@ func resourceStreamingSinkDelete(ctx context.Context, resourceData *schema.Resou
144146
sinkName := resourceData.Get("sink_name").(string)
145147
namespace := resourceData.Get("namespace").(string)
146148

147-
pulsarClusterName := resourceData.Get("pulsar_cluster").(string)
149+
pulsarClusterFromConfig := resourceData.Get("pulsar_cluster").(string)
148150
rawRegion := resourceData.Get("region").(string)
149151
region := strings.ReplaceAll(rawRegion, "-", "")
150152
cloudProvider := resourceData.Get("cloud_provider").(string)
151153

152-
pulsarCluster := getPulsarCluster(pulsarClusterName, cloudProvider, region, "")
154+
if pulsarClusterFromConfig == "" {
155+
if cloudProvider == "" || region == "" {
156+
return diag.Errorf("failed to configure resource, pulsar_cluster or cloud_provider and region must be set")
157+
}
158+
}
159+
pulsarCluster := getPulsarCluster(pulsarClusterFromConfig, cloudProvider, region, "")
153160

154161
orgResp, err := astraClient.GetCurrentOrganization(ctx)
155162
if err != nil {

internal/provider/util_streaming.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ func getPulsarCluster(clusterName, cloudProvider, region, suffix string) string
171171
}
172172
// In most astra APIs there are dashes in region names depending on the cloud provider, this seems not to be the case for streaming
173173
normalizedRegion := strings.ReplaceAll(region, "-", "")
174+
if cloudProvider == "" || normalizedRegion == "" {
175+
return ""
176+
}
174177
return strings.ToLower(fmt.Sprintf("pulsar-%s-%s%s", cloudProvider, normalizedRegion, suffix))
175178
}
176179

0 commit comments

Comments
 (0)