diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 29a71385..1d22744f 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -94,6 +94,7 @@ resource "biganimal_cluster" "single_node_cluster" { pgvector = false post_gis = false + pg_bouncer = { is_enabled = false # settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults. @@ -275,6 +276,7 @@ output "faraway_replica_ids" { - `storage` (Block, Optional) Storage. (see [below for nested schema](#nestedblock--storage)) - `superuser_access` (Boolean) Enable to grant superuser access to the edb_admin role. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `volume_snapshot_backup`(Boolean) Enable to take a snapshot of the volume. ### Read-Only diff --git a/examples/data-sources/biganimal_cluster/data-source.tf b/examples/data-sources/biganimal_cluster/data-source.tf index eae3db74..0b10c642 100644 --- a/examples/data-sources/biganimal_cluster/data-source.tf +++ b/examples/data-sources/biganimal_cluster/data-source.tf @@ -112,3 +112,7 @@ output "pe_allowed_principal_ids" { output "service_account_ids" { value = data.biganimal_cluster.this.service_account_ids } + +output "volume_snapshot_backup" { + value = coalesce(data.biganimal_cluster.this.post_gis, false) +} diff --git a/examples/resources/biganimal_cluster/ha/resource.tf b/examples/resources/biganimal_cluster/ha/resource.tf index 8e664986..92820785 100644 --- a/examples/resources/biganimal_cluster/ha/resource.tf +++ b/examples/resources/biganimal_cluster/ha/resource.tf @@ -74,15 +74,16 @@ resource "biganimal_cluster" "ha_cluster" { start_time = "03:00" } - pg_type = "epas" - pg_version = "15" - private_networking = false - cloud_provider = "bah:aws" // "bah:aws" uses BigAnimal's cloud account AWS, use "aws" for your cloud account - read_only_connections = true - region = "us-east-1" - superuser_access = true - pgvector = false - post_gis = false + pg_type = "epas" + pg_version = "15" + private_networking = false + cloud_provider = "bah:aws" // "bah:aws" uses BigAnimal's cloud account AWS, use "aws" for your cloud account + read_only_connections = true + region = "us-east-1" + superuser_access = true + pgvector = false + post_gis = false + volume_snapshot_backup = false pg_bouncer = { is_enabled = false diff --git a/examples/resources/biganimal_cluster/single_node/aws/resource.tf b/examples/resources/biganimal_cluster/single_node/aws/resource.tf index ef3af970..a3389322 100644 --- a/examples/resources/biganimal_cluster/single_node/aws/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/aws/resource.tf @@ -75,15 +75,16 @@ resource "biganimal_cluster" "single_node_cluster" { start_time = "03:00" } - pg_type = "epas" - pg_version = "15" - private_networking = false - cloud_provider = "bah:aws" // "bah:aws" uses BigAnimal's cloud account AWS, use "aws" for your cloud account - read_only_connections = false - region = "us-east-1" - superuser_access = true - pgvector = false - post_gis = false + pg_type = "epas" + pg_version = "15" + private_networking = false + cloud_provider = "bah:aws" // "bah:aws" uses BigAnimal's cloud account AWS, use "aws" for your cloud account + read_only_connections = false + region = "us-east-1" + superuser_access = true + pgvector = false + post_gis = false + volume_snapshot_backup = false pg_bouncer = { is_enabled = false diff --git a/examples/resources/biganimal_cluster/single_node/azure/resource.tf b/examples/resources/biganimal_cluster/single_node/azure/resource.tf index 0505096b..479570bd 100644 --- a/examples/resources/biganimal_cluster/single_node/azure/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/azure/resource.tf @@ -75,15 +75,17 @@ resource "biganimal_cluster" "single_node_cluster" { start_time = "03:00" } - pg_type = "epas" - pg_version = "15" - private_networking = false - cloud_provider = "bah:azure" // "bah:azure" uses BigAnimal's cloud account Azure, use "azure" for your cloud account - read_only_connections = false - region = "eastus2" - superuser_access = true - pgvector = false - post_gis = false + pg_type = "epas" + pg_version = "15" + private_networking = false + cloud_provider = "bah:azure" // "bah:azure" uses BigAnimal's cloud account Azure, use "azure" for your cloud account + read_only_connections = false + region = "eastus2" + superuser_access = true + pgvector = false + post_gis = false + volume_snapshot_backup = false + pg_bouncer = { is_enabled = false diff --git a/examples/resources/biganimal_cluster/single_node/gcp/resource.tf b/examples/resources/biganimal_cluster/single_node/gcp/resource.tf index ee164899..155edb09 100644 --- a/examples/resources/biganimal_cluster/single_node/gcp/resource.tf +++ b/examples/resources/biganimal_cluster/single_node/gcp/resource.tf @@ -75,15 +75,17 @@ resource "biganimal_cluster" "single_node_cluster" { start_time = "03:00" } - pg_type = "epas" - pg_version = "15" - private_networking = false - cloud_provider = "bah:gcp" // "bah:gpc" uses BigAnimal's cloud account Google Cloud provider, use "gcp" for your cloud account - read_only_connections = false - region = "us-east1" - superuser_access = true - pgvector = false - post_gis = false + pg_type = "epas" + pg_version = "15" + private_networking = false + cloud_provider = "bah:gcp" // "bah:gpc" uses BigAnimal's cloud account Google Cloud provider, use "gcp" for your cloud account + read_only_connections = false + region = "us-east1" + superuser_access = true + pgvector = false + post_gis = false + volume_snapshot_backup = false + pg_bouncer = { is_enabled = false diff --git a/pkg/models/cluster.go b/pkg/models/cluster.go index 694eaca7..ff22648e 100644 --- a/pkg/models/cluster.go +++ b/pkg/models/cluster.go @@ -171,6 +171,7 @@ type Cluster struct { SuperuserAccess *bool `json:"superuserAccess,omitempty"` Extensions *[]ClusterExtension `json:"extensions,omitempty"` PgBouncer *PgBouncer `json:"pgBouncer,omitempty"` + VolumeSnapshot *bool `json:"volumeSnapshotBackup,omitempty"` EncryptionKeyIdReq *string `json:"keyId,omitempty"` EncryptionKeyResp *EncryptionKey `json:"encryptionKey,omitempty"` PgIdentity *string `json:"pgIdentity,omitempty"` diff --git a/pkg/plan_modifier/pg_bouncer.go b/pkg/plan_modifier/pg_bouncer.go index cf6de463..0694ce03 100644 --- a/pkg/plan_modifier/pg_bouncer.go +++ b/pkg/plan_modifier/pg_bouncer.go @@ -89,12 +89,6 @@ func (m CustomPgBouncerModifier) PlanModifyObject(ctx context.Context, req planm return } - if !reqPlanIsEnabled.ValueBool() && !reqPlanSettings.IsUnknown() && len(reqPlanSettings.Elements()) == 0 { - resp.Diagnostics.AddError("if pg_bouncer.is_enabled = false then pg_bouncer.settings cannot be []", "please remove pg_bouncer.settings or set pg_bouncer.settings = null") - - return - } - // if is_enabled = false and settings is null and state setting is null then use state value for unknown if !reqPlanIsEnabled.ValueBool() && req.ConfigValue.Attributes()["settings"].(basetypes.SetValue).IsNull() && diff --git a/pkg/provider/data_source_cluster.go b/pkg/provider/data_source_cluster.go index 47131be8..351fb0ce 100644 --- a/pkg/provider/data_source_cluster.go +++ b/pkg/provider/data_source_cluster.go @@ -382,6 +382,10 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq Optional: true, Computed: true, }, + "volume_snapshot_backup": schema.BoolAttribute{ + MarkdownDescription: "Volume snapshot.", + Optional: true, + }, }, } } diff --git a/pkg/provider/resource_cluster.go b/pkg/provider/resource_cluster.go index 74b48283..7d9cc7a2 100644 --- a/pkg/provider/resource_cluster.go +++ b/pkg/provider/resource_cluster.go @@ -79,6 +79,7 @@ type ClusterResourceModel struct { TransparentDataEncryption *TransparentDataEncryptionModel `tfsdk:"transparent_data_encryption"` PgIdentity types.String `tfsdk:"pg_identity"` TransparentDataEncryptionAction types.String `tfsdk:"transparent_data_encryption_action"` + VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"` Timeouts timeouts.Value `tfsdk:"timeouts"` } @@ -440,6 +441,11 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest Optional: true, Computed: true, }, + "volume_snapshot_backup": schema.BoolAttribute{ + MarkdownDescription: "Enable to take a snapshot of the volume.", + Optional: true, + PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}, + }, "pgvector": schema.BoolAttribute{ MarkdownDescription: "Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.", Optional: true, @@ -818,6 +824,7 @@ func readCluster(ctx context.Context, client *api.ClusterClient, tfClusterResour tfClusterResource.PrivateNetworking = types.BoolPointerValue(responseCluster.PrivateNetworking) tfClusterResource.SuperuserAccess = types.BoolPointerValue(responseCluster.SuperuserAccess) tfClusterResource.PgIdentity = types.StringPointerValue(responseCluster.PgIdentity) + tfClusterResource.VolumeSnapshot = types.BoolPointerValue(responseCluster.VolumeSnapshot) if responseCluster.EncryptionKeyResp != nil && *responseCluster.Phase != constants.PHASE_HEALTHY { if !tfClusterResource.PgIdentity.IsNull() && tfClusterResource.PgIdentity.ValueString() != "" { @@ -1050,6 +1057,7 @@ func (c *clusterResource) generateGenericClusterModel(ctx context.Context, clust ReadOnlyConnections: clusterResource.ReadOnlyConnections.ValueBoolPointer(), BackupRetentionPeriod: clusterResource.BackupRetentionPeriod.ValueStringPointer(), SuperuserAccess: clusterResource.SuperuserAccess.ValueBoolPointer(), + VolumeSnapshot: clusterResource.VolumeSnapshot.ValueBoolPointer(), } cluster.Extensions = &[]models.ClusterExtension{}