Extending Google Cloud PostgreSQL provider


I’m trying to get Terraform to list available backups from a postgreSQL instance that was provisioned using Terraform. How do I make the API call (rest/v1beta4/backupRuns/list)?

Method: backupRuns.list

Lists all backup runs associated with the project or a given instance and configuration in the reverse chronological order of the backup initiation time.

HTTP request

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/backupRuns

The URL uses gRPC Transcoding syntax.

Path parameters

project string

Project ID of the project that contains the instance.
instance string

Cloud SQL instance ID, or “-” for all instances. This does not include the project ID.

I’ve been trying to create a custom provider but still could not get my head wrapped around it to get it to work. Is this the correct route I should be taking? Any inputs would be greatly appreciated. I am also new to Go.

Ultimately, I would like to be able to select a backup timestamp, supply that to Terraform as a string variable and Terraform apply would create a new instance based on that timestamp.


  • Mario

Created a simple custom provider (data source) binary, was able to run Terraform init and Terraform plan but encountered this error which halted Terraform plan:

2022/02/22 16:15:03 [TRACE] statemgr.Filesystem: unlocked by closing terraform.tfstate
2022-02-22T16:15:03.649-0600 [WARN] plugin.stdio: received EOF, stopping recv loop: err=“rpc error: code = Unavailable desc = transport is closing”
Error: Invalid data source

on main.tf line 15, in data “gcp” “backup”:
15: data “gcp” “backup” {

The provider provider.gcp does not support data source “gcp”.

2022-02-22T16:15:03.658-0600 [DEBUG] plugin: plugin process exited: path=C:\Users\mario.tejada\go\src\github.com\poj89\gcp-1\terraform.d\plugins\windows_amd64\terraform-provider-gcp_v1.0.1.exe pid=28564
2022-02-22T16:15:03.658-0600 [DEBUG] plugin: plugin exited

Any ideas on how to fix this error?

Git repo: poj89/gcp: test repo (github.com)