-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Bug Description
Hello! I'm trying to connect to Google cloudsql Mariadb database using worload identity federation from AWS. Here is the code I run:
func connectWithProxy(conf config.GCPDB) (*sqlx.DB, error) {
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" {
// just a check to make sure credentials.DetectDefault will detect correct file
return nil, fmt.Errorf("GOOGLE_APPLICATION_CREDENTIALS environment variable not set")
}
creds, err := credentials.DetectDefault(&credentials.DetectOptions{
Scopes: []string{storage.CloudPlatformScope},
})
if err != nil {
return nil, errl.Source(err)
}
if _, err := mysql.RegisterDriver("cloudsql-mysql", cloudsqlconn.WithCredentials(creds)); err != nil {
return nil, errl.Source(err)
}
dbConn := fmt.Sprintf(
"%s:%s@cloudsql-mysql(%s)/%s?parseTime=true",
conf.User, conf.Password, conf.Host, conf.Name,
)
db, err := sql.Open(
"cloudsql-mysql",
dbConn,
)
if err != nil {
return nil, errl.Source(err)
}
return sqlx.NewDb(db, "mysql"), nil
}But it gives me error failed to get instance: refresh error: failed to get instance metadata (connection name = "ccs-wfm:europe-west3:ccs-wfm"): Get "https://sqladmin.googleapis.com/sql/v1beta4/projects/ccs-wfm/instances/ccs-wfm/connectSettings?alt=json&prettyPrint=false\": unexpected end of JSON input
Example code (or command)
Stacktrace
Steps to reproduce?
- ?
- ?
- ?
...
Environment
- OS type and version: alpine-3.12:latest
- Go version: 1.24.4
- Cloud SQL Go Connector version: v1.18.1
Additional Details
No response
Metadata
Metadata
Assignees
Labels
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.