Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PSC Private Service Connect for GCP CloudSQL #27889

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/27889.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:improvement
secrets/database: Add PSC support for GCP CloudSQL MySQL and Postgresql
```
```release-note:improvement
secrets/database: Add PrivateIP support for MySQL
```
7 changes: 5 additions & 2 deletions plugins/database/mysql/connection_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@
}

// validate auth_type if provided
if ok := connutil.ValidateAuthType(c.AuthType); !ok {
return nil, fmt.Errorf("invalid auth_type: %s", c.AuthType)
authType := c.AuthType
if authType != "" {
if ok := connutil.ValidateAuthType(authType); !ok {
return nil, fmt.Errorf("invalid auth_type %s provided", authType)
}
}

if c.AuthType == connutil.AuthTypeGCPIAM {
Expand Down Expand Up @@ -319,7 +322,7 @@
}

func registerDriverMySQL(driverName, credentials string) (cleanup func() error, err error) {
opts, err := connutil.GetCloudSQLAuthOptions(credentials, false)

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / artifacts / (linux, amd64)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests tagged with testonly / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests tagged with testonly / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests tagged with testonly / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests tagged with testonly / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (12)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (12)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (6)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (6)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (10)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (10)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (8)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (8)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (2)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (2)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (9)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (9)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (13)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (13)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (15)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (15)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (16)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (1)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (6)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (6)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (11)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (11)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (0)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (14)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (14)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (3)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (2)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (2)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (4)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (4)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (8)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (8)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (7)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (7)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (14)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (14)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (9)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (9)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (13)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (13)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (12)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (12)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (4)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests / test-go (4)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (11)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (11)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (5)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (7)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (7)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (15)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (15)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (10)

not enough arguments in call to connutil.GetCloudSQLAuthOptions

Check failure on line 325 in plugins/database/mysql/connection_producer.go

View workflow job for this annotation

GitHub Actions / Run Go tests with data race detection / test-go (10)

not enough arguments in call to connutil.GetCloudSQLAuthOptions
if err != nil {
return nil, err
}
Expand Down
10 changes: 7 additions & 3 deletions sdk/database/helper/connutil/cloudsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func (c *SQLConnectionProducer) getCloudSQLDriverType() (string, error) {
return driverType, nil
}

func (c *SQLConnectionProducer) registerDrivers(driverName string, credentials string, usePrivateIP bool) (func() error, error) {
func (c *SQLConnectionProducer) registerDrivers(driverName string, credentials string, usePrivateIP bool, usePSC bool) (func() error, error) {
typ, err := c.getCloudSQLDriverType()
if err != nil {
return nil, err
}

opts, err := GetCloudSQLAuthOptions(credentials, usePrivateIP)
opts, err := GetCloudSQLAuthOptions(credentials, usePrivateIP, usePSC)
if err != nil {
return nil, err
}
Expand All @@ -45,7 +45,7 @@ func (c *SQLConnectionProducer) registerDrivers(driverName string, credentials s

// GetCloudSQLAuthOptions takes a credentials JSON and returns
// a set of GCP CloudSQL options - always WithIAMAUthN, and then the appropriate file/JSON option.
func GetCloudSQLAuthOptions(credentials string, usePrivateIP bool) ([]cloudsqlconn.Option, error) {
func GetCloudSQLAuthOptions(credentials string, usePrivateIP bool, usePSC bool) ([]cloudsqlconn.Option, error) {
opts := []cloudsqlconn.Option{cloudsqlconn.WithIAMAuthN()}

if credentials != "" {
Expand All @@ -56,5 +56,9 @@ func GetCloudSQLAuthOptions(credentials string, usePrivateIP bool) ([]cloudsqlco
opts = append(opts, cloudsqlconn.WithDefaultDialOptions(cloudsqlconn.WithPrivateIP()))
}

if usePSC {
opts = append(opts, cloudsqlconn.WithDefaultDialOptions(cloudsqlconn.WithPSC()))
}

return opts, nil
}
5 changes: 3 additions & 2 deletions sdk/database/helper/connutil/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type SQLConnectionProducer struct {
MaxIdleConnections int `json:"max_idle_connections" mapstructure:"max_idle_connections" structs:"max_idle_connections"`
MaxConnectionLifetimeRaw interface{} `json:"max_connection_lifetime" mapstructure:"max_connection_lifetime" structs:"max_connection_lifetime"`
DisableEscaping bool `json:"disable_escaping" mapstructure:"disable_escaping" structs:"disable_escaping"`
usePrivateIP bool `json:"use_private_ip" mapstructure:"use_private_ip" structs:"use_private_ip"`
UsePrivateIP bool `json:"use_private_ip" mapstructure:"use_private_ip" structs:"use_private_ip"`
UsePSC bool `json:"use_psc" mapstructure:"use_psc" structs:"use_psc"`
Comment on lines +56 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will be returned in the READ response for all database plugins that embed this SQLConnectionProducer struct. That is not ideal, since they are only relevant to a small subset of database plugins. It might be better to implement this per-plugin similar to mysql. Maybe there is some common code that could be reused by each plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is already the case for

	AuthType           string `json:"auth_type" mapstructure:"auth_type" structs:"auth_type"`
	ServiceAccountJSON string `json:"service_account_json" mapstructure:"service_account_json" structs:"service_account_json"`

Which is only supported for Postgresql, but still field is available for hana, mssql, redshift

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually I was able to remove from the read path, when auth_type is not gcp_iam

Test (did the same test with mysql as well)
Postgresql
Write and read using auth_typegcp_iam

vault write database/config/my-postgresql-database-psc \ 
         plugin_name="postgresql-database-plugin" \
        allowed_roles="my-role" \
connection_url="host=sej-tools-hashicorp:asia-northeast1:psc-enabled-main-instance [email protected] dbname=postgres sslmode=disable" \
        auth_type="gcp_iam" 
        use_psc=true
Success! Data written to: database/config/my-postgresql-database-psc

vault read database/config/my-postgresql-database-psc
Key                                   Value
---                                   -----
allowed_roles                         [my-role]
connection_details                    map[auth_type:gcp_iam connection_url:host=sej-tools-hashicorp:asia-northeast1:psc-enabled-main-instance [email protected] dbname=postgres sslmode=disable use_psc:true]
password_policy                       n/a
plugin_name                           postgresql-database-plugin
plugin_version                        n/a
root_credentials_rotate_statements    []

Write and read using normal plugin and normal auth

vault write database/config/my-postgresql-database-psc-ip      \
         plugin_name=postgresql-database-plugin \
         connection_url="postgresql://{{username}}:{{password}}@127.0.0.1/postgres?sslmode=disable"   \
         allowed_roles=readonly \
         username="admin"  \
         password="XXXXXx"
Success! Data written to: database/config/my-postgresql-database-psc-ip


vault read database/config/my-postgresql-database-psc-ip
Key                                   Value
---                                   -----
allowed_roles                         [readonly]
connection_details                    map[connection_url:postgresql://{{username}}:{{password}}@127.0.0.1/postgres?sslmode=disable username:admin]
password_policy                       n/a
plugin_name                           postgresql-database-plugin
plugin_version                        n/a
root_credentials_rotate_statements    []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong about this. See my comment here https://github.com/hashicorp/vault/pull/27889/files#r1720329947


// Username/Password is the default auth type when AuthType is not set
Username string `json:"username" mapstructure:"username" structs:"username"`
Expand Down Expand Up @@ -151,7 +152,7 @@ func (c *SQLConnectionProducer) Init(ctx context.Context, conf map[string]interf
// however, the driver might store a credentials file, in which case the state stored by the driver is in
// fact critical to the proper function of the connection. So it needs to be registered here inside the
// ConnectionProducer init.
dialerCleanup, err := c.registerDrivers(c.cloudDriverName, c.ServiceAccountJSON, c.usePrivateIP)
dialerCleanup, err := c.registerDrivers(c.cloudDriverName, c.ServiceAccountJSON, c.UsePrivateIP, c.UsePSC)
if err != nil {
return nil, err
}
Expand Down
6 changes: 6 additions & 0 deletions website/content/api-docs/secret/databases/mysql-maria.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ has a number of parameters to further configure a connection.
- `service_account_json` `(string: "")` - JSON encoded credentials for a GCP Service Account to use
for IAM authentication. Requires `auth_type` to be `gcp_iam`.

- `use_private_ip` `(boolean: false)` - Enables the option to connect to CloudSQL Instances with Private IP.
Requires `auth_type` to be `gcp_iam`.

- `use_psc` `(boolean: false)` - Enables the option to connect to CloudSQL Instances with Private Service Connect.
Requires `auth_type` to be `gcp_iam`.

- `tls_certificate_key` `(string: "")` - x509 certificate for connecting to the database.
This must be a PEM encoded version of the private key and the certificate combined.

Expand Down
3 changes: 3 additions & 0 deletions website/content/api-docs/secret/databases/postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ has a number of parameters to further configure a connection.
- `use_private_ip` `(boolean: false)` - Enables the option to connect to CloudSQL Instances with Private IP.
Requires `auth_type` to be `gcp_iam`.

- `use_psc` `(boolean: false)` - Enables the option to connect to CloudSQL Instances with Private Service Connect.
Requires `auth_type` to be `gcp_iam`.

- `username_template` `(string)` - [Template](/vault/docs/concepts/username-templating) describing how
dynamic usernames are generated.

Expand Down
4 changes: 4 additions & 0 deletions website/content/docs/secrets/databases/mysql-maria.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ GRANT SELECT, CREATE, CREATE USER ON <database>.<object> TO "test-user"@"%" WITH
plugin_name="mysql-database-plugin" \
allowed_roles="my-role" \
connection_url="user@cloudsql-mysql(project:region:instance)/mysql" \
use_private_ip="false" \
use_psc="false" \
auth_type="gcp_iam"
```

Expand All @@ -214,6 +216,8 @@ GRANT SELECT, CREATE, CREATE USER ON <database>.<object> TO "test-user"@"%" WITH
allowed_roles="my-role" \
connection_url="user@cloudsql-mysql(project:region:instance)/mysql" \
auth_type="gcp_iam" \
use_private_ip="false" \
use_psc="false" \
service_account_json="@my_credentials.json"
```

Expand Down
2 changes: 2 additions & 0 deletions website/content/docs/secrets/databases/postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ ALTER USER "<YOUR DB USERNAME>" WITH CREATEROLE;
allowed_roles="my-role" \
connection_url="host=project:us-west1:mydb [email protected] dbname=postgres sslmode=disable" \
use_private_ip="false" \
use_psc="false" \
auth_type="gcp_iam"
```

Expand All @@ -141,6 +142,7 @@ ALTER USER "<YOUR DB USERNAME>" WITH CREATEROLE;
allowed_roles="my-role" \
connection_url="host=project:region:instance [email protected] dbname=postgres sslmode=disable" \
use_private_ip="false" \
use_psc="false" \
auth_type="gcp_iam" \
service_account_json="@my_credentials.json"
```
Expand Down
Loading