Skip to content

Commit c08f5f6

Browse files
authored
fix bug in streaming tenant import (#444)
After importing a streaming tenant, some state values are still unknown. Make sure that the region in the state is not overridden by an empty plan value. Also deprecate the use of cloud_provider and region for streaming tenant.
1 parent 534d6d4 commit c08f5f6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

docs/resources/streaming_tenant.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ output "web_socket_url" {
7575

7676
### Optional
7777

78-
- `cloud_provider` (String) Cloud provider, one of `aws`, `gcp`, or `azure`. Required if `cluster_name` is not set.
78+
- `cloud_provider` (String, Deprecated) Cloud provider, one of `aws`, `gcp`, or `azure`. Required if `cluster_name` is not set.
7979
- `cluster_name` (String) Pulsar cluster name. Required if `cloud_provider` and `region` are not specified.
8080
- `deletion_protection` (Boolean) Whether or not to allow Terraform to destroy this tenant. 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`.
81-
- `region` (String) Cloud provider region. Required if `cluster_name` is not set.
81+
- `region` (String, Deprecated) Cloud provider region. Required if `cluster_name` is not set.
8282
- `topic` (String, Deprecated) Streaming tenant topic. Please use the `astra_streaming_topic` resource instead.
8383

8484
### Read-Only

internal/provider/resource_streaming_tenant.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,19 @@ func (r *StreamingTenantResource) Schema(_ context.Context, _ resource.SchemaReq
8080
},
8181
},
8282
"cloud_provider": schema.StringAttribute{
83-
Description: "Cloud provider, one of `aws`, `gcp`, or `azure`. Required if `cluster_name` is not set.",
84-
Optional: true,
85-
Computed: true,
83+
DeprecationMessage: "'cluster_name' should be used instead of 'cloud_provider' and 'region'.",
84+
Description: "Cloud provider, one of `aws`, `gcp`, or `azure`. Required if `cluster_name` is not set.",
85+
Optional: true,
86+
Computed: true,
8687
PlanModifiers: []planmodifier.String{
87-
stringplanmodifier.RequiresReplace(),
88+
stringplanmodifier.RequiresReplaceIfConfigured(),
8889
},
8990
},
9091
"region": schema.StringAttribute{
91-
Description: "Cloud provider region. Required if `cluster_name` is not set.",
92-
Optional: true,
93-
Computed: true,
92+
DeprecationMessage: "'cluster_name' should be used instead of 'cloud_provider' and 'region'.",
93+
Description: "Cloud provider region. Required if `cluster_name` is not set.",
94+
Optional: true,
95+
Computed: true,
9496
PlanModifiers: []planmodifier.String{
9597
//removeDashesModifier{},
9698
//suppressDashesDiffModifier{},
@@ -315,7 +317,9 @@ func (r *StreamingTenantResource) Update(ctx context.Context, req resource.Updat
315317

316318
state.DeletionProtection = plan.DeletionProtection
317319
state.UserEmail = plan.UserEmail
318-
state.Region = plan.Region
320+
if !plan.Region.IsNull() && !plan.Region.IsUnknown() {
321+
state.Region = plan.Region
322+
}
319323

320324
// Save updated data into Terraform state
321325
resp.Diagnostics.Append(resp.State.Set(ctx, state)...)

0 commit comments

Comments
 (0)