Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: backup schedule time #609

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ output "backup_retention_period" {
value = data.biganimal_analytics_cluster.this.backup_retention_period
}

output "backup_schedule_time" {
value = data.biganimal_analytics_cluster.this.backup_schedule_time
}

output "cluster_name" {
value = data.biganimal_analytics_cluster.this.cluster_name
}
Expand Down
4 changes: 4 additions & 0 deletions examples/data-sources/biganimal_cluster/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ output "backup_retention_period" {
value = data.biganimal_cluster.this.backup_retention_period
}

output "backup_schedule_time" {
value = data.biganimal_cluster.this.backup_schedule_time
}

output "cluster_name" {
value = data.biganimal_cluster.this.cluster_name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ output "backup_retention_period" {
value = data.biganimal_faraway_replica.this.backup_retention_period
}

output "backup_schedule_time" {
value = data.biganimal_faraway_replica.this.backup_schedule_time
}

output "cluster_name" {
value = data.biganimal_faraway_replica.this.cluster_name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ resource "biganimal_analytics_cluster" "analytics_cluster" {
]

backup_retention_period = "30d"
csp_auth = false
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
csp_auth = false

instance_type = "aws:m6id.12xlarge"
password = resource.random_password.password.result
Expand Down
1 change: 1 addition & 0 deletions examples/resources/biganimal_cluster/ha/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "biganimal_cluster" "ha_cluster" {
]

backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
id = "ha"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "biganimal_cluster" "single_node_cluster" {
]

backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
id = "single"
nodes = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "biganimal_cluster" "single_node_cluster" {
]

backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
id = "single"
nodes = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "biganimal_cluster" "single_node_cluster" {
]

backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
id = "single"
nodes = 1
Expand Down
5 changes: 3 additions & 2 deletions examples/resources/biganimal_faraway_replica/aws/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ resource "biganimal_faraway_replica" "faraway_replica" {
]

backup_retention_period = "8d"
csp_auth = false
instance_type = "aws:c6i.large"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
csp_auth = false
instance_type = "aws:c6i.large"

// only following pg_config parameters are configurable for faraway replica
// max_connections, max_locks_per_transaction, max_prepared_transactions, max_wal_senders, max_worker_processes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ resource "biganimal_faraway_replica" "faraway_replica" {
]

backup_retention_period = "8d"
csp_auth = false
instance_type = "azure:Standard_D2s_v3"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
csp_auth = false
instance_type = "azure:Standard_D2s_v3"

// only following pg_config parameters are configurable for faraway replica
// max_connections, max_locks_per_transaction, max_prepared_transactions, max_wal_senders, max_worker_processes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ resource "biganimal_faraway_replica" "faraway_replica" {
]

backup_retention_period = "8d"
csp_auth = false
instance_type = "azure:Standard_D2s_v3"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
csp_auth = false
instance_type = "azure:Standard_D2s_v3"

// only following pg_config parameters are configurable for faraway replica
// max_connections, max_locks_per_transaction, max_prepared_transactions, max_wal_senders, max_worker_processes.
Expand Down
5 changes: 3 additions & 2 deletions examples/resources/biganimal_faraway_replica/gcp/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ resource "biganimal_faraway_replica" "faraway_replica" {
]

backup_retention_period = "8d"
csp_auth = false
instance_type = "gcp:e2-highcpu-4"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
csp_auth = false
instance_type = "gcp:e2-highcpu-4"

// only following pg_config parameters are configurable for faraway replica
// max_connections, max_locks_per_transaction, max_prepared_transactions, max_wal_senders, max_worker_processes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down Expand Up @@ -111,6 +112,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down Expand Up @@ -111,6 +112,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down Expand Up @@ -115,6 +116,7 @@ resource "biganimal_pgd" "pgd_cluster" {
},
]
backup_retention_period = "6d"
# backup_schedule_time = "0 5 1 * * *" //24 hour format cron expression e.g. "0 5 1 * * *" is 01:05
cluster_architecture = {
cluster_architecture_id = "pgd"
nodes = 3
Expand Down
1 change: 1 addition & 0 deletions pkg/models/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type Cluster struct {
EncryptionKeyIdReq *string `json:"keyId,omitempty"`
EncryptionKeyResp *EncryptionKey `json:"encryptionKey,omitempty"`
PgIdentity *string `json:"pgIdentity,omitempty"`
BackupScheduleTime *string `json:"scheduleBackup,omitempty"`
}

// IsHealthy checks to see if the cluster has the right condition 'biganimal.com/deployed'
Expand Down
5 changes: 4 additions & 1 deletion pkg/models/pgd/api/data_group.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package api

import "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models"
import (
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models"
)

type DataGroup struct {
GroupId *string `json:"groupId,omitempty"`
Expand Down Expand Up @@ -30,4 +32,5 @@ type DataGroup struct {
PeAllowedPrincipalIds *[]string `json:"peAllowedPrincipalIds,omitempty"`
RoConnectionUri *string `json:"roConnectionUri,omitempty"`
ReadOnlyConnections *bool `json:"readOnlyConnections,omitempty"`
BackupScheduleTime *string `json:"scheduleBackup,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/models/pgd/terraform/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ type DataGroup struct {
PeAllowedPrincipalIds types.Set `tfsdk:"pe_allowed_principal_ids"`
RoConnectionUri types.String `tfsdk:"ro_connection_uri"`
ReadOnlyConnections *bool `tfsdk:"read_only_connections"`
BackupScheduleTime types.String `tfsdk:"backup_schedule_time"`
}
7 changes: 7 additions & 0 deletions pkg/provider/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
commonApi "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models/common/api"
commonTerraform "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models/common/terraform"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
Expand Down Expand Up @@ -31,3 +32,9 @@ func buildAPIReqAssignTags(tfRsrcTags []commonTerraform.Tag) []commonApi.Tag {
}
return tags
}

var ResourceBackupScheduleTime = schema.StringAttribute{
MarkdownDescription: "Backup schedule time in 24 hour format.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backup schedule time in 24 hour cron expression format.

Optional: true,
Computed: true,
}
1 change: 1 addition & 0 deletions pkg/provider/data_source_analytics_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (r *analyticsClusterDataSource) Schema(ctx context.Context, req datasource.
},
},
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/data_source_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq
MarkdownDescription: "Cluster connection service name.",
Computed: true,
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/data_source_fareplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ func (c *FAReplicaData) Schema(ctx context.Context, req datasource.SchemaRequest
},
},
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/data_source_pgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (p pgdDataSource) Schema(ctx context.Context, req datasource.SchemaRequest,
Description: "Is read-only connections enabled.",
Computed: true,
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/resource_analytics_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type analyticsClusterResourceModel struct {
PeAllowedPrincipalIds types.Set `tfsdk:"pe_allowed_principal_ids"`
Pause types.Bool `tfsdk:"pause"`
Tags []commonTerraform.Tag `tfsdk:"tags"`
BackupScheduleTime types.String `tfsdk:"backup_schedule_time"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -301,6 +302,7 @@ func (r *analyticsClusterResource) Schema(ctx context.Context, req resource.Sche
plan_modifier.CustomAssignTags(),
},
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down Expand Up @@ -406,6 +408,7 @@ func generateAnalyticsClusterModelCreate(ctx context.Context, client *api.Cluste
CSPAuth: clusterResource.CspAuth.ValueBoolPointer(),
PrivateNetworking: clusterResource.PrivateNetworking.ValueBoolPointer(),
BackupRetentionPeriod: clusterResource.BackupRetentionPeriod.ValueStringPointer(),
BackupScheduleTime: clusterResource.BackupScheduleTime.ValueStringPointer(),
}

cluster.ClusterId = nil
Expand Down Expand Up @@ -505,6 +508,7 @@ func readAnalyticsCluster(ctx context.Context, client *api.ClusterClient, tfClus
tfClusterResource.LogsUrl = responseCluster.LogsUrl
tfClusterResource.MetricsUrl = responseCluster.MetricsUrl
tfClusterResource.BackupRetentionPeriod = types.StringPointerValue(responseCluster.BackupRetentionPeriod)
tfClusterResource.BackupScheduleTime = types.StringPointerValue(responseCluster.BackupScheduleTime)
tfClusterResource.PgVersion = types.StringValue(responseCluster.PgVersion.PgVersionId)
tfClusterResource.PgType = types.StringValue(responseCluster.PgType.PgTypeId)
tfClusterResource.PrivateNetworking = types.BoolPointerValue(responseCluster.PrivateNetworking)
Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type ClusterResourceModel struct {
VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"`
Tags []commonTerraform.Tag `tfsdk:"tags"`
ServiceName types.String `tfsdk:"service_name"`
BackupScheduleTime types.String `tfsdk:"backup_schedule_time"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -575,6 +576,7 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest
Computed: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down Expand Up @@ -856,6 +858,7 @@ func readCluster(ctx context.Context, client *api.ClusterClient, tfClusterResour
tfClusterResource.LogsUrl = responseCluster.LogsUrl
tfClusterResource.MetricsUrl = responseCluster.MetricsUrl
tfClusterResource.BackupRetentionPeriod = types.StringPointerValue(responseCluster.BackupRetentionPeriod)
tfClusterResource.BackupScheduleTime = types.StringPointerValue(responseCluster.BackupScheduleTime)
tfClusterResource.PgVersion = types.StringValue(responseCluster.PgVersion.PgVersionId)
tfClusterResource.PgType = types.StringValue(responseCluster.PgType.PgTypeId)
tfClusterResource.FarawayReplicaIds = StringSliceToSet(responseCluster.FarawayReplicaIds)
Expand Down Expand Up @@ -1098,6 +1101,7 @@ func (c *clusterResource) generateGenericClusterModel(ctx context.Context, clust
PrivateNetworking: clusterResource.PrivateNetworking.ValueBoolPointer(),
ReadOnlyConnections: clusterResource.ReadOnlyConnections.ValueBoolPointer(),
BackupRetentionPeriod: clusterResource.BackupRetentionPeriod.ValueStringPointer(),
BackupScheduleTime: clusterResource.BackupScheduleTime.ValueStringPointer(),
SuperuserAccess: clusterResource.SuperuserAccess.ValueBoolPointer(),
VolumeSnapshot: clusterResource.VolumeSnapshot.ValueBoolPointer(),
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/provider/resource_fareplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type FAReplicaResourceModel struct {
TransparentDataEncryptionAction types.String `tfsdk:"transparent_data_encryption_action"`
VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"`
Tags []commonTerraform.Tag `tfsdk:"tags"`
BackupScheduleTime types.String `tfsdk:"backup_schedule_time"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -422,6 +423,7 @@ func (r *FAReplicaResource) Schema(ctx context.Context, req resource.SchemaReque
plan_modifier.CustomAssignTags(),
},
},
"backup_schedule_time": ResourceBackupScheduleTime,
},
}
}
Expand Down Expand Up @@ -625,6 +627,7 @@ func readFAReplica(ctx context.Context, client *api.ClusterClient, fAReplicaReso
fAReplicaResourceModel.LogsUrl = responseCluster.LogsUrl
fAReplicaResourceModel.MetricsUrl = responseCluster.MetricsUrl
fAReplicaResourceModel.BackupRetentionPeriod = types.StringPointerValue(responseCluster.BackupRetentionPeriod)
fAReplicaResourceModel.BackupScheduleTime = types.StringPointerValue(responseCluster.BackupScheduleTime)
fAReplicaResourceModel.PrivateNetworking = types.BoolPointerValue(responseCluster.PrivateNetworking)
fAReplicaResourceModel.ClusterArchitecture = &ClusterArchitectureResourceModel{
Id: responseCluster.ClusterArchitecture.ClusterArchitectureId,
Expand Down Expand Up @@ -768,6 +771,7 @@ func (r *FAReplicaResource) generateGenericFAReplicaModel(ctx context.Context, f
CSPAuth: fAReplicaResourceModel.CspAuth.ValueBoolPointer(),
PrivateNetworking: fAReplicaResourceModel.PrivateNetworking.ValueBoolPointer(),
BackupRetentionPeriod: fAReplicaResourceModel.BackupRetentionPeriod.ValueStringPointer(),
BackupScheduleTime: fAReplicaResourceModel.BackupScheduleTime.ValueStringPointer(),
}

allowedIpRanges := []models.AllowedIpRange{}
Expand Down
Loading
Loading