diff --git a/.changelog/8227.txt b/.changelog/8227.txt new file mode 100644 index 00000000000..c1a8749fee0 --- /dev/null +++ b/.changelog/8227.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +gkebackup: added `state` and `state_reason` output-only fields to `google_gkebackup_backupplan` resource +``` diff --git a/google/services/gkebackup/resource_gke_backup_backup_plan.go b/google/services/gkebackup/resource_gke_backup_backup_plan.go index 312ef8e2dfa..62b4659220f 100644 --- a/google/services/gkebackup/resource_gke_backup_backup_plan.go +++ b/google/services/gkebackup/resource_gke_backup_backup_plan.go @@ -265,6 +265,16 @@ backupPlans.delete to ensure that their change will be applied to the same versi Computed: true, Description: `The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan.`, }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: `The State of the BackupPlan.`, + }, + "state_reason": { + Type: schema.TypeString, + Computed: true, + Description: `Detailed description of why BackupPlan is in its current state.`, + }, "uid": { Type: schema.TypeString, Computed: true, @@ -479,6 +489,12 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("protected_pod_count", flattenGKEBackupBackupPlanProtectedPodCount(res["protectedPodCount"], d, config)); err != nil { return fmt.Errorf("Error reading BackupPlan: %s", err) } + if err := d.Set("state", flattenGKEBackupBackupPlanState(res["state"], d, config)); err != nil { + return fmt.Errorf("Error reading BackupPlan: %s", err) + } + if err := d.Set("state_reason", flattenGKEBackupBackupPlanStateReason(res["stateReason"], d, config)); err != nil { + return fmt.Errorf("Error reading BackupPlan: %s", err) + } return nil } @@ -914,6 +930,14 @@ func flattenGKEBackupBackupPlanProtectedPodCount(v interface{}, d *schema.Resour return v // let terraform core handle it otherwise } +func flattenGKEBackupBackupPlanState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenGKEBackupBackupPlanStateReason(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func expandGKEBackupBackupPlanName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/backupPlans/{{name}}") } diff --git a/website/docs/r/gke_backup_backup_plan.html.markdown b/website/docs/r/gke_backup_backup_plan.html.markdown index d51b3e7d829..d2bfdd3223a 100644 --- a/website/docs/r/gke_backup_backup_plan.html.markdown +++ b/website/docs/r/gke_backup_backup_plan.html.markdown @@ -365,6 +365,12 @@ In addition to the arguments listed above, the following computed attributes are * `protected_pod_count` - The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan. +* `state` - + The State of the BackupPlan. + +* `state_reason` - + Detailed description of why BackupPlan is in its current state. + ## Timeouts