cockroachdb / terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Apache License 2.0
55 stars 10 forks source link

Use new private endpoint connections API #183

Closed carloruiz closed 3 months ago

carloruiz commented 3 months ago
Previously, the private_endpoint_connection resource only supported AWS
private link connections. This commit updates the provider code to use
the new CC API Private Endpoint Connections methods. These cloud-neutral
methods will work for all cloud providers and cluster types, except
Serverless clusters on Azure as that configuration is not yet
supported.

Commit checklist

carloruiz commented 3 months ago

perhaps the contents should be update as part of this to reflect the correct usage.

ack. will update

Along similar lines, I'm wondering if there is any necessary migration as part of this or period where we need to keep a deprecated resource name around?

Fortunately, we're not deprecating any TF fields as part of this change.

carloruiz commented 3 months ago

Acceptance test: had do manually change some code to make this work. There's no straight-forward way to automatically test Private endpoint connection creation bc the client needs to create the endpoint out of band before calling the API. I created the endpoint manually and hardcoded the endpoint id into the test.

COCKROACH_API_KEY=<KEY> COCKROACH_SERVER=https://management-staging.crdb.io TF_ACC=1 make test
go test ./... -run TestAccServerlessPrivateEndpointConnectionResource -v  -timeout 20m
?       github.com/cockroachdb/terraform-provider-cockroach [no test files]
?       github.com/cockroachdb/terraform-provider-cockroach/mock    [no test files]
=== RUN   TestAccServerlessPrivateEndpointConnectionResource
=== PAUSE TestAccServerlessPrivateEndpointConnectionResource
=== CONT  TestAccServerlessPrivateEndpointConnectionResource
--- PASS: TestAccServerlessPrivateEndpointConnectionResource (68.70s)
PASS
ok      github.com/cockroachdb/terraform-provider-cockroach/internal/provider   69.241s
carloruiz commented 3 months ago

Actually I was able to add a fixture for the serverless test so it runs with the acceptance tests. It will reuse the real, existing endpoint id.