Skip to content

Commit ab027d5

Browse files
author
Siddarth Baldwa
committed
Added backup regions to cluster region info
1 parent 659d9b1 commit ab027d5

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

managed/data_source_cluster_name.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ func (r dataClusterNameType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Di
9797
Computed: true,
9898
},
9999
"backup_replication_gcp_target": {
100-
Description: "GCS bucket name for backup replication target. Only configurable when editing existing clusters. For SYNCHRONOUS clusters, all regions must have the same target. For GEO_PARTITIONED clusters, each region can have different targets. Only supported for GCP clusters and PAID tier.",
100+
Description: "GCS bucket name set as backup replication target.",
101101
Type: types.StringType,
102102
Computed: true,
103103
},
104+
"backup_region": {
105+
Description: "Indicates whether cluster backup data will be stored in this region.",
106+
Type: types.BoolType,
107+
Computed: true,
108+
},
104109
}),
105110
},
106111
"backup_schedules": {

managed/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type RegionInfo struct {
106106
IsPreferred types.Bool `tfsdk:"is_preferred"`
107107
IsDefault types.Bool `tfsdk:"is_default"`
108108
BackupReplicationGCPTarget types.String `tfsdk:"backup_replication_gcp_target"`
109+
BackupRegion types.Bool `tfsdk:"backup_region"`
109110
}
110111

111112
type NodeConfig struct {

managed/resource_cluster.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func (r resourceClusterType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Di
183183
),
184184
},
185185
},
186+
"backup_region": {
187+
Description: "Indicates whether cluster backup data will be stored in this region.",
188+
Type: types.BoolType,
189+
Computed: true,
190+
},
186191
}),
187192
},
188193
"backup_schedules": {
@@ -2011,6 +2016,16 @@ func resourceClusterRead(ctx context.Context, accountId string, projectId string
20112016
tflog.Info(ctx, fmt.Sprintf("Siddarth no target. Set null %v", cluster.ClusterName))
20122017
}
20132018

2019+
// Handle backup region - get from cluster_region_info_details
2020+
backupRegion := types.Bool{Value: false}
2021+
// Find the corresponding region info details to get backup_region
2022+
for _, regionDetail := range clusterResp.Data.Info.ClusterRegionInfoDetails {
2023+
if regionDetail.Region == region {
2024+
backupRegion = types.Bool{Value: regionDetail.BackupRegion}
2025+
break
2026+
}
2027+
}
2028+
20142029
regionInfo := RegionInfo{
20152030
Region: types.String{Value: region},
20162031
NumNodes: types.Int64{Value: int64(info.PlacementInfo.GetNumNodes())},
@@ -2023,6 +2038,7 @@ func resourceClusterRead(ctx context.Context, accountId string, projectId string
20232038
IsPreferred: types.Bool{Value: info.GetIsAffinitized()},
20242039
IsDefault: types.Bool{Value: info.GetIsDefault()},
20252040
BackupReplicationGCPTarget: backupReplicationGCPTarget,
2041+
BackupRegion: backupRegion,
20262042
}
20272043
clusterRegionInfo[destIndex] = regionInfo
20282044
}

0 commit comments

Comments
 (0)