Hello,
We recently encountered an error when creating a backup plan for GKE.
The error we’re specifically getting is:
Error creating BackupPlan: googleapi: Error 400: backup_plan_id field is required and must be 1-63 characters long and match
a-z ?: invalid argument
In the debug we see that the request body does not include a directive for backup_plan_id but google is reporting it missing.
That said, Method: projects.locations.backupPlans.create | Backup for GKE | Google Cloud the api reference that says the definition of the body must include a BackupPlan configuration https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/reference/rest/v1/projects.locations.backupPlans#BackupPlan that has no mention of a required backup_name_id parameter to be set.
I’d be happy to provide further information, but I do not see how this is directly a terraform problem as the definition of the API as provided by google does not specify the requirement
I have discovered this in the google cloud node folder of the googleapis repository in github:
message CreateBackupPlanRequest {
// Required. The location within which to create the BackupPlan.
// Format: `projects/*/locations/*`
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];
// Required. The BackupPlan resource object to create.
BackupPlan backup_plan = 2 [(google.api.field_behavior) = REQUIRED];
// Required. The client-provided short name for the BackupPlan resource.
// This name must:
//
// - be between 1 and 63 characters long (inclusive)
// - consist of only lower-case ASCII letters, numbers, and dashes
// - start with a lower-case letter
// - end with a lower-case letter or number
This file has been truncated. show original
Does list the backup_name_id
to be REQUIRED for completion of the request
As of August 4th, the construct for the API create backup plan method, does in fact note and require a backup_plan_id
to be set and sent with the request payload to the API.
Also, it is noted that the json example snippets also include a backup_plan_id
in the example payloads:
"parameters": [
{
"name": "parent",
"type": "TYPE_STRING"
},
{
"name": "backup_plan",
"type": ".google.cloud.gkebackup.v1.BackupPlan"
},
{
"name": "backup_plan_id",
"type": "TYPE_STRING"
}
],
"resultType": ".google.longrunning.Operation",
"client": {
"shortName": "BackupForGKEClient",
"fullName": "google.cloud.gkebackup.v1.BackupForGKEClient"
},
"method": {
"shortName": "CreateBackupPlan",
"parameters": [
{
"name": "parent",
"type": "TYPE_STRING"
},
{
"name": "backup_plan",
"type": ".google.cloud.gkebackup.v1.BackupPlan"
},
{
"name": "backup_plan_id",
"type": "TYPE_STRING"
}
],
"resultType": ".google.longrunning.Operation",
"client": {
"shortName": "BackupForGKEClient",
"fullName": "google.cloud.gkebackup.v1.BackupForGKEClient"
},
"method": {
"shortName": "CreateBackupPlan",
The error we’re receiving when creating a GKE backup plan is saying that the payload to the API did not include a definition for backup_plan_name
which makes complete sense, as the https://github.com/hashicorp/terraform-provider-google/blob/3756dc0ac753ab6b312094ab0f96f89307f492f8/google/services/gkebackup/resource_gke_backup_backup_plan.go#L317 does not construct one currently.
Looking at the full repository I cannot even see a reference to backup_plan_id
currently in the terraform google provider: https://github.com/search?q=repo%3Ahashicorp%2Fterraform-provider-google+backup_plan_id&type=code
I will be creating an issue in github to address this further.
Github Issue Created for further investigation and resolution.
opened 02:20PM - 17 Oct 23 UTC
bug
forward/review
service/gkebackup
### Community Note
* Please vote on this issue by adding a 👍 [reaction](https… ://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request.
* Please do not leave _+1_ or _me too_ comments, they generate extra noise for issue followers and do not help prioritize the request.
* If you are interested in working on this issue or have submitted a pull request, please leave a comment.
* If an issue is assigned to the `modular-magician` user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to `hashibot`, a community member has claimed the issue already.
---
### Terraform Version
```
### Terraform Version2023-10-17T08:31:43.163-0500 [INFO] Terraform version: 1.5.7
2023-10-17T08:31:43.163-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-10-17T08:31:43.163-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-10-17T08:31:43.163-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2023-10-17T08:31:43.163-0500 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2023-10-17T08:31:43.163-0500 [INFO] Go runtime version: go1.21.1
2023-10-17T08:31:43.163-0500 [INFO] CLI args: []string{"terraform", "apply", "tplan.tfstate"}
```
### Affected Resource(s)
`google_gke_backup_backup_plan`
### Terraform Configuration Files
```tf
resource "google_gke_backup_backup_plan" "basic_dev_cluster_basic" {
name = "basic_dev_cluster_full_backup_plan"
cluster = google_container_cluster.basic_dev_cluster.id
location = "us-central1"
backup_config {
include_volume_data = true
include_secrets = true
all_namespaces = true
}
}
```
### Debug Output
```
2023-10-17T08:31:45.315-0500 [INFO] Starting apply for google_gke_backup_backup_plan.basic_dev_cluster_basic
2023-10-17T08:31:45.319-0500 [DEBUG] google_gke_backup_backup_plan.basic_dev_cluster_basic: applying the planned Create change
2023-10-17T08:31:45.319-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] setting computed for "effective_labels" from ComputedKeys
2023-10-17T08:31:45.319-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] setting computed for "terraform_labels" from ComputedKeys
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Creating new BackupPlan: map[string]interface {}{"backupConfig":map[string]interface {}{"allNamespaces":true, "includeSecrets":true, "includeVolumeData":true}, "cluster":"projects/[REDACTED]/locations/us-central1-c/clusters/basic-dev-cluster", "name":"projects/[REDACTED]/locations/us-central1/backupPlans/basic_dev_cluster_full_backup_plan"}
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Waiting for state to become: [success]
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Retry Transport: starting RoundTrip retry loop
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Retry Transport: request attempt 0
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Google API Request Details:
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: ---[ REQUEST ]---------------------------------------
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: POST /v1/projects/[REDACTED]/locations/us-central1/backupPlans?alt=json&backupPlanId=basic_dev_cluster_full_backup_plan HTTP/1.1
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Host: gkebackup.googleapis.com
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: User-Agent: Terraform/1.5.7 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google/5.1.0
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Content-Length: 284
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Content-Type: application/json
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Accept-Encoding: gzip
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5:
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: {
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "backupConfig": {
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "allNamespaces": true,
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "includeSecrets": true,
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "includeVolumeData": true
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: },
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "cluster": "projects/[REDACTED]/locations/us-central1-c/clusters/basic-dev-cluster",
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "name": "projects/[REDACTED]/locations/us-central1/backupPlans/basic_dev_cluster_full_backup_plan"
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: }
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5:
2023-10-17T08:31:45.320-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: -----------------------------------------------------
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Google API Response Details:
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: ---[ RESPONSE ]--------------------------------------
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: HTTP/2.0 400 Bad Request
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Cache-Control: private
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Content-Type: application/json; charset=UTF-8
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Cross-Origin-Opener-Policy-Report-Only: same-origin; report-to="gfe-default_product_name"
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Date: Tue, 17 Oct 2023 13:31:45 GMT
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Report-To: {"group":"gfe-default_product_name","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/report-to/default_product_name"}]}
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Server: ESF
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: Origin
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: X-Origin
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: Referer
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Content-Type-Options: nosniff
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Frame-Options: SAMEORIGIN
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Xss-Protection: 0
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5:
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: {
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "error": {
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "code": 400,
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "message": "backup_plan_id field is required and must be 1-63 characters long and match `[a-z]([-a-z0-9]*[a-z0-9])?`: invalid argument",
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "status": "INVALID_ARGUMENT"
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: }
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: }
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5:
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: -----------------------------------------------------
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Retry Transport: Stopping retries, last request failed with non-retryable error: googleapi: got HTTP response code 400 with body: HTTP/2.0 400 Bad Request
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2023-10-17T08:31:45.817-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Cache-Control: private
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Content-Type: application/json; charset=UTF-8
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Cross-Origin-Opener-Policy-Report-Only: same-origin; report-to="gfe-default_product_name"
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Date: Tue, 17 Oct 2023 13:31:45 GMT
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Report-To: {"group":"gfe-default_product_name","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/report-to/default_product_name"}]}
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Server: ESF
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: Origin
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: X-Origin
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: Vary: Referer
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Content-Type-Options: nosniff
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Frame-Options: SAMEORIGIN
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: X-Xss-Protection: 0
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5:
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: {
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "error": {
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "code": 400,
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "message": "backup_plan_id field is required and must be 1-63 characters long and match `[a-z]([-a-z0-9]*[a-z0-9])?`: invalid argument",
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: "status": "INVALID_ARGUMENT"
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: }
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: }
2023-10-17T08:31:45.818-0500 [DEBUG] provider.terraform-provider-google_v5.1.0_x5: 2023/10/17 08:31:45 [DEBUG] Retry Transport: Returning after 1 attempts
2023-10-17T08:31:45.818-0500 [ERROR] provider.terraform-provider-google_v5.1.0_x5: Response contains error diagnostic: diagnostic_detail= diagnostic_summary="Error creating BackupPlan: googleapi: Error 400: backup_plan_id field is required and must be 1-63 characters long and match `[a-z]([-a-z0-9]*[a-z0-9])?`: invalid argument" tf_req_id=f26e61ed-f58e-95e6-4285-d22ad1f68b6f tf_resource_type=google_gke_backup_backup_plan tf_provider_addr=registry.terraform.io/hashicorp/google tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_severity=ERROR tf_proto_version=5.3 @module=sdk.proto timestamp=2023-10-17T08:31:45.818-0500
2023-10-17T08:31:45.821-0500 [DEBUG] State storage *remote.State declined to persist a state snapshot
2023-10-17T08:31:45.821-0500 [ERROR] vertex "google_gke_backup_backup_plan.basic_dev_cluster_basic" error: Error creating BackupPlan: googleapi: Error 400: backup_plan_id field is required and must be 1-63 characters long and match `[a-z]([-a-z0-9]*[a-z0-9])?`: invalid argument
2023-10-17T08:31:45.821-0500 [DEBUG] states/remote: state read serial is: 369; serial is: 369
2023-10-17T08:31:45.821-0500 [DEBUG] states/remote: state read lineage is: 6661c828-61de-dfcb-70d4-116af3ce7eaf; lineage is: 6661c828-61de-dfcb-70d4-116af3ce7eaf
╷
│ Error: Error creating BackupPlan: googleapi: Error 400: backup_plan_id field is required and must be 1-63 characters long and match `[a-z]([-a-z0-9]*[a-z0-9])?`: invalid argument
│
│ with google_gke_backup_backup_plan.basic_dev_cluster_basic,
│ on GKE-Basic-Dev-Cluster.tf line 25, in resource "google_gke_backup_backup_plan" "basic_dev_cluster_basic":
│ 25: resource "google_gke_backup_backup_plan" "basic_dev_cluster_basic" {
│
╵
```
### Expected Behavior
The configuration should create the GKE Backup Plan with the directives required by the API
### Actual Behavior
The request payload to the API server was rejected because of a missing `backup_plan_id` declaration in the body
### Steps to Reproduce
Seems to fail no matter what when trying to apply the configuration
### Important Factoids
I started a thread on the hashi forums here: https://discuss.hashicorp.com/t/error-in-creation-of-google-gke-backup-backup-plan/59182/2
### References
My analysis thus far has come to the following conclusions:
https://cloud.google.com/php/docs/reference/cloud-gke-backup/latest/V1.CreateBackupPlanRequest#methods
Includes a requirement for `backup_plan_id` to be included in the request to complete the method
The current function to create a new gke backup plan does not set a `backup_plan_id` value and thus one is never deployed with the request payload.
https://github.com/hashicorp/terraform-provider-google/blob/3756dc0ac753ab6b312094ab0f96f89307f492f8/google/services/gkebackup/resource_gke_backup_backup_plan.go#L317-L440
Looking at the google side of things:
https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-gkebackup/samples/generated/v1/snippet_metadata.google.cloud.gkebackup.v1.json#L43
https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-gkebackup/samples/generated/v1/snippet_metadata_google.cloud.gkebackup.v1.json
Both snippets include the required `backup_plan_id`
Looking at the source for the API it does seem to be indicative of a hard requirement for the GKE backup creation method:
https://github.com/googleapis/google-cloud-node/blame/main/packages/google-cloud-gkebackup/protos/google/cloud/gkebackup/v1/gkebackup.proto#L363-L371
It is also documented as a requirement in the API reference documentation
https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/reference/rest/v1/projects.locations.backupPlans/create#query-parameters
<!---
Note Google Cloud customers who are working with a dedicated Technical Account Manager / Customer Engineer: to expedite the investigation and resolution of this issue, please refer to these instructions: https://github.com/hashicorp/terraform-provider-google/wiki/Customer-Contact#raising-gcp-internal-issues-with-the-provider-development-team
--->