diff --git a/examples/data-sources/biganimal_cluster/data-source.tf b/examples/data-sources/biganimal_cluster/data-source.tf index 9bbddfd3..035d86ac 100644 --- a/examples/data-sources/biganimal_cluster/data-source.tf +++ b/examples/data-sources/biganimal_cluster/data-source.tf @@ -101,6 +101,10 @@ output "superuser_access" { value = coalesce(data.biganimal_cluster.this.superuser_access, false) } +output "pgvector" { + value = coalesce(data.biganimal_cluster.this.pgvector, false) +} + output "faraway_replica_ids" { value = data.biganimal_cluster.this.faraway_replica_ids } diff --git a/examples/resources/biganimal_cluster/ha/resource.tf b/examples/resources/biganimal_cluster/ha/resource.tf index bfbb067e..d70137e4 100644 --- a/examples/resources/biganimal_cluster/ha/resource.tf +++ b/examples/resources/biganimal_cluster/ha/resource.tf @@ -78,6 +78,7 @@ resource "biganimal_cluster" "ha_cluster" { read_only_connections = true region = "us-east-1" superuser_access = true + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/aws/resource.tf b/examples/resources/biganimal_cluster/single_node/aws/resource.tf index 60335a4b..cb251fa5 100644 --- a/examples/resources/biganimal_cluster/single_node/aws/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/aws/resource.tf @@ -79,6 +79,7 @@ resource "biganimal_cluster" "single_node_cluster" { read_only_connections = false region = "us-east-1" superuser_access = true + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/azure/resource.tf b/examples/resources/biganimal_cluster/single_node/azure/resource.tf index 00a241e6..7254ac99 100644 --- a/examples/resources/biganimal_cluster/single_node/azure/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/azure/resource.tf @@ -79,6 +79,7 @@ resource "biganimal_cluster" "single_node_cluster" { read_only_connections = false region = "eastus2" superuser_access = true + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/bah_aws/resource.tf b/examples/resources/biganimal_cluster/single_node/bah_aws/resource.tf index 02aa6fe1..52bf3b4b 100644 --- a/examples/resources/biganimal_cluster/single_node/bah_aws/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/bah_aws/resource.tf @@ -77,6 +77,7 @@ resource "biganimal_cluster" "single_node_cluster" { cloud_provider = "bah:aws" read_only_connections = false region = "us-east-1" + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/bah_azure/resource.tf b/examples/resources/biganimal_cluster/single_node/bah_azure/resource.tf index 076136e3..de8e18d1 100644 --- a/examples/resources/biganimal_cluster/single_node/bah_azure/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/bah_azure/resource.tf @@ -78,6 +78,7 @@ resource "biganimal_cluster" "single_node_cluster" { cloud_provider = "bah:azure" read_only_connections = false region = "eastus2" + pgvector = true # pe_allowed_principal_ids = [ # # ex: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A" # ] diff --git a/examples/resources/biganimal_cluster/single_node/bah_gcp/resource.tf b/examples/resources/biganimal_cluster/single_node/bah_gcp/resource.tf index 339480a5..f4a45453 100644 --- a/examples/resources/biganimal_cluster/single_node/bah_gcp/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/bah_gcp/resource.tf @@ -71,6 +71,7 @@ resource "biganimal_cluster" "single_node_cluster" { cloud_provider = "bah:gcp" read_only_connections = false region = "europe-west1" + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/gcp/resource.tf b/examples/resources/biganimal_cluster/single_node/gcp/resource.tf index 4098bd90..a25db34a 100644 --- a/examples/resources/biganimal_cluster/single_node/gcp/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/gcp/resource.tf @@ -79,6 +79,7 @@ resource "biganimal_cluster" "single_node_cluster" { read_only_connections = false region = "us-east1" superuser_access = true + pgvector = true } output "password" { diff --git a/examples/resources/biganimal_cluster/single_node/resource.tf b/examples/resources/biganimal_cluster/single_node/resource.tf index 00a241e6..7254ac99 100644 --- a/examples/resources/biganimal_cluster/single_node/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/resource.tf @@ -79,6 +79,7 @@ resource "biganimal_cluster" "single_node_cluster" { read_only_connections = false region = "eastus2" superuser_access = true + pgvector = true } output "password" { diff --git a/pkg/models/cluster.go b/pkg/models/cluster.go index 8b41293b..abcc429f 100644 --- a/pkg/models/cluster.go +++ b/pkg/models/cluster.go @@ -173,6 +173,7 @@ type Cluster struct { ServiceAccountIds *[]string `json:"serviceAccountIds,omitempty"` PeAllowedPrincipalIds *[]string `json:"peAllowedPrincipalIds,omitempty"` SuperuserAccess *bool `json:"superuserAccess,omitempty"` + Extensions *[]ClusterExtension `json:"extensions,omitempty"` } // IsHealthy checks to see if the cluster has the right condition 'biganimal.com/deployed' diff --git a/pkg/models/cluster_extension.go b/pkg/models/cluster_extension.go new file mode 100644 index 00000000..266fb574 --- /dev/null +++ b/pkg/models/cluster_extension.go @@ -0,0 +1,6 @@ +package models + +type ClusterExtension struct { + Enabled bool `json:"enabled"` + ExtensionId string `json:"extensionId"` +} diff --git a/pkg/provider/data_source_cluster.go b/pkg/provider/data_source_cluster.go index a828690e..2a95accb 100644 --- a/pkg/provider/data_source_cluster.go +++ b/pkg/provider/data_source_cluster.go @@ -336,6 +336,10 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq MarkdownDescription: "Is superuser access enabled.", Computed: true, }, + "pgvector": schema.BoolAttribute{ + MarkdownDescription: "Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.", + Computed: true, + }, }, } } diff --git a/pkg/provider/resource_cluster.go b/pkg/provider/resource_cluster.go index a5daf8cf..12576983 100644 --- a/pkg/provider/resource_cluster.go +++ b/pkg/provider/resource_cluster.go @@ -69,6 +69,7 @@ type ClusterResourceModel struct { ServiceAccountIds types.Set `tfsdk:"service_account_ids"` PeAllowedPrincipalIds types.Set `tfsdk:"pe_allowed_principal_ids"` SuperuserAccess types.Bool `tfsdk:"superuser_access"` + Pgvector types.Bool `tfsdk:"pgvector"` Timeouts timeouts.Value `tfsdk:"timeouts"` } @@ -391,6 +392,12 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest Optional: true, Computed: true, }, + "pgvector": schema.BoolAttribute{ + MarkdownDescription: "Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.", + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}, + }, }, } } @@ -581,6 +588,14 @@ func (c *clusterResource) read(ctx context.Context, clusterResource *ClusterReso clusterResource.FarawayReplicaIds = StringSliceToSet(cluster.FarawayReplicaIds) clusterResource.PrivateNetworking = types.BoolPointerValue(cluster.PrivateNetworking) clusterResource.SuperuserAccess = types.BoolPointerValue(cluster.SuperuserAccess) + if cluster.Extensions != nil { + for _, v := range *cluster.Extensions { + if v.Enabled && v.ExtensionId == "pgvector" { + clusterResource.Pgvector = types.BoolValue(true) + break + } + } + } if cluster.FirstRecoverabilityPointAt != nil { firstPointAt := cluster.FirstRecoverabilityPointAt.String() @@ -730,6 +745,11 @@ func generateGenericClusterModel(clusterResource ClusterResourceModel) models.Cl SuperuserAccess: clusterResource.SuperuserAccess.ValueBoolPointer(), } + cluster.Extensions = &[]models.ClusterExtension{} + if clusterResource.Pgvector.ValueBool() { + *cluster.Extensions = append(*cluster.Extensions, models.ClusterExtension{Enabled: true, ExtensionId: "pgvector"}) + } + allowedIpRanges := []models.AllowedIpRange{} for _, ipRange := range clusterResource.AllowedIpRanges { allowedIpRanges = append(allowedIpRanges, models.AllowedIpRange{ diff --git a/pkg/provider/resource_cluster_test.go b/pkg/provider/resource_cluster_test.go index cc80d2d7..36719534 100644 --- a/pkg/provider/resource_cluster_test.go +++ b/pkg/provider/resource_cluster_test.go @@ -105,6 +105,7 @@ func clusterResourceConfig(cluster_name, projectID, provider, region string) str private_networking = false read_only_connections = false superuser_access = true + pgvector = true }`, cluster_name, projectID, provider, region) } @@ -157,5 +158,6 @@ func clusterResourceConfigForUpdate(cluster_name, projectID, provider, region st private_networking = false read_only_connections = false superuser_access = true + pgvector = true }`, cluster_name, projectID, provider, region) }