Skip to content

Commit

Permalink
feat: snapshot volume backup for faraway replica (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
wai-wong-edb authored Aug 6, 2024
1 parent ece83ea commit 6f95fd6
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ output "resizing_pvc" {
output "storage" {
value = data.biganimal_faraway_replica.this.storage
}

output "storage" {
value = data.biganimal_faraway_replica.this.volume_snapshot_backup
}
2 changes: 2 additions & 0 deletions examples/resources/biganimal_faraway_replica/aws/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ resource "biganimal_faraway_replica" "faraway_replica" {
# transparent_data_encryption = {
# key_id = <example_value>
# }

volume_snapshot_backup = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ resource "biganimal_faraway_replica" "faraway_replica" {
# transparent_data_encryption = {
# key_id = <example_value>
# }

volume_snapshot_backup = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ resource "biganimal_cluster" "single_node_cluster" {
# transparent_data_encryption = {
# key_id = <example_value>
# }

volume_snapshot_backup = false
}

output "password" {
Expand Down Expand Up @@ -107,4 +109,6 @@ resource "biganimal_faraway_replica" "faraway_replica" {
# transparent_data_encryption = {
# key_id = <example_value>
# }

volume_snapshot_backup = false
}
2 changes: 2 additions & 0 deletions examples/resources/biganimal_faraway_replica/gcp/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ resource "biganimal_faraway_replica" "faraway_replica" {
# transparent_data_encryption = {
# key_id = <example_value>
# }

volume_snapshot_backup = false
}
30 changes: 30 additions & 0 deletions pkg/provider/data_source_fareplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@ func (c *FAReplicaData) Schema(ctx context.Context, req datasource.SchemaRequest
Description: "Cloud provider. For example, \"aws\", \"azure\", \"gcp\" or \"bah:aws\", \"bah:gcp\".",
Computed: true,
},
"volume_snapshot_backup": schema.BoolAttribute{
MarkdownDescription: "Enable to take a snapshot of the volume.",
Computed: true,
},
"transparent_data_encryption": schema.SingleNestedAttribute{
MarkdownDescription: "Transparent Data Encryption (TDE) key",
Optional: true,
Attributes: map[string]schema.Attribute{
"key_id": schema.StringAttribute{
MarkdownDescription: "Transparent Data Encryption (TDE) key ID.",
Required: true,
},
"key_name": schema.StringAttribute{
MarkdownDescription: "Key name.",
Computed: true,
},
"status": schema.StringAttribute{
MarkdownDescription: "Status.",
Computed: true,
},
},
},
"pg_identity": schema.StringAttribute{
MarkdownDescription: "PG Identity required to grant key permissions to activate the cluster.",
Computed: true,
},
"transparent_data_encryption_action": schema.StringAttribute{
MarkdownDescription: "Transparent data encryption action.",
Computed: true,
},
},
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/resource_fareplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type FAReplicaResourceModel 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"`
}
Expand Down Expand Up @@ -381,6 +382,11 @@ func (r *FAReplicaResource) Schema(ctx context.Context, req resource.SchemaReque
Computed: true,
PlanModifiers: []planmodifier.String{plan_modifier.CustomTDEAction()},
},
"volume_snapshot_backup": schema.BoolAttribute{
MarkdownDescription: "Enable to take a snapshot of the volume.",
Optional: true,
PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()},
},
},
}
}
Expand Down Expand Up @@ -594,6 +600,7 @@ func readFAReplica(ctx context.Context, client *api.ClusterClient, fAReplicaReso
fAReplicaResourceModel.CloudProvider = types.StringValue(responseCluster.Provider.CloudProviderId)
fAReplicaResourceModel.PgVersion = types.StringValue(responseCluster.PgVersion.PgVersionId)
fAReplicaResourceModel.PgType = types.StringValue(responseCluster.PgType.PgTypeId)
fAReplicaResourceModel.VolumeSnapshot = types.BoolPointerValue(responseCluster.VolumeSnapshot)

// pgConfig. If tf resource pg config elem matches with api response pg config elem then add the elem to tf resource pg config
newPgConfig := []PgConfigResourceModel{}
Expand Down

0 comments on commit 6f95fd6

Please sign in to comment.