MCPcopy Index your code
hub / github.com/expel-io/vault-plugin-database-cloudsql

github.com/expel-io/vault-plugin-database-cloudsql @0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.2.0 ↗ · + Follow
19 symbols 59 edges 7 files 8 documented · 42%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

vault-plugin-database-cloudsql

This is a Hashicorp Vault database plugin to connect to CloudSQL instances with GoogleCloudPlatform/cloud-sql-go-connector.

Compatibility

  • This plugin currently only supports connecting to postgres CloudSQL instances. PRs welcome!
  • This plugin has been tested with Hashicorp Vault version 1.8.x. Stay tuned as we add support for newer Hashicorp Vault versions.

From Google Cloud's documentation:

Using the Cloud SQL Auth proxy is the recommended method for connecting to a Cloud SQL instance. See: Connect using the Cloud SQL Auth proxy

By using the cloud-sql-go-connector Hashicorp Vault is able to connect to multiple CloudSQL instances without the need for the Cloud SQL Auth Proxy.

This plugin does two things:

  1. Initializes the database driver with the cloud-sql-go-connector allowing it to connect securely with Google IAM credentials.
  2. It then defers to Hashicorp Vault's original database plugins for all database specific interactions.

NOTE: Currently support is limited to Postgres instances.

Arguments

The following plugin arguments are supported:

  • -db-type, defaults to cloudsql-postgres. This is currently the only supported database type.
  • -log-level, defaults to info
  • multiplex, defaults to true

Getting Started

1. Building the plugin

Build the plugin binary for your target architecture:

make build

2. Install the plugin binary

After the plugin is built, it must be made available to the Vault server runtime. Move the compiled plugin into Vault's configured plugin_directory:

# in the following example the `plugin_directory` is `/etc/vault/plugins`
mv vault-plugin-database-cloudsql /etc/vault/plugins/vault-plugin-database-cloudsql

3. Calculate the SHA of the plugin

# save the output of this to register your plugin on the next step
sha256sum /app/bin/plugins/vault-plugin-database-cloudsql

4. Register the plugin with terraform

After building this plugin and making it available to your Vault runtime, you can register the plugin to the plugin catalog like this:

resource "vault_generic_endpoint" "configure_custom_cloudsql_plugin" {
  path                 = "sys/plugins/catalog/database/vault-plugin-database-cloudsql"
  disable_read         = false
  disable_delete       = false
  ignore_absent_fields = true

  data_json = jsonencode({
    type    = "database"
    sha_256 = <INSERT-YOUR-BINARY-SHA>
    command = "vault-plugin-database-cloudsql"
    args = [
        "-db-type=cloudsql-postgres",
        "-log-level=info"
    ]
  })
}

For an in depth guide see our quickstart folder

Development

In order to run unit tests, run the following command:

make test

Core symbols most depended-on inside this repo

String
called by 9
dbtype.go
Serve
called by 2
cmd/vault-plugin-database-cloudsql/serve.go
New
called by 1
cloudsql.go
Type
called by 1
cloudsql.go
newPostgresDatabase
called by 1
cloudsql.go
FromString
called by 1
dbtype.go
initServeConfig
called by 1
cmd/vault-plugin-database-cloudsql/serve.go
Initialize
called by 0
cloudsql.go

Shape

Function 10
Method 7
Struct 1
TypeAlias 1

Languages

Go100%

Modules by API surface

cloudsql.go9 symbols
dbtype.go3 symbols
dbtype_test.go2 symbols
cmd/vault-plugin-database-cloudsql/serve.go2 symbols
cmd/vault-plugin-database-cloudsql/serve_test.go1 symbols
cmd/vault-plugin-database-cloudsql/main.go1 symbols
cloudsql_test.go1 symbols

For agents

$ claude mcp add vault-plugin-database-cloudsql \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact