Vault Plugin: Google Cloud Platform Auth Backend
This is a standalone backend plugin for use with HashiCorp Vault. This plugin allows for various GCP entities to authenticate with Vault. This is currently included in Vault distributions.
Currently, this plugin supports login for:
- IAM service accounts
- GCE Instances
Please note: We take Vault's security and our users' trust very seriously. If you believe you have found a security issue in Vault, please responsibly disclose by contacting us at firstname.lastname@example.org.
This is a Vault plugin and is meant to work with Vault. This guide assumes you have already installed Vault and have a basic understanding of how Vault works.
Otherwise, first read this guide on how to get started with Vault.
To learn specifically about how plugins work, see documentation on Vault plugins.
Please see documentation for the plugin on the Vault website.
This plugin is currently built into Vault and by default is accessed
auth/gcp. To enable this in a running Vault server:
$ vault auth enable gcp Success! Enabled gcp auth method at: gcp/
To see all the supported paths, see the GCP auth backend docs.
Please note that local development is only required if you plan to contribute or compile this plugin yourself. This plugin is automatically bundled in Vault installations and is available by default. You do not need to compile it yourself unless you intend to modify it.
If you wish to work on this plugin, you'll first need Go installed on your machine (version 1.10+ is required).
For local dev first make sure Go is properly installed, including
setting up a GOPATH.
Next, clone this repository into your
$ mkdir -p $GOPATH/src/github.com/hashicorp $ git clone https://github.com/hashicorp/vault-plugin-auth-gcp $GOPATH/src/github.com/hashicorp/ $ cd vault-plugin-auth-gcp
You can then download any required build tools by bootstrapping your environment:
$ make bootstrap
To compile a development version of this plugin, run
This will put the plugin binary in the
mode will only generate the binary for your platform and is faster:
$ make $ make dev
For local development, use Vault's "dev" mode for fast setup:
$ vault server -dev -dev-plugin-dir="$(pwd)/bin"
The plugin will automatically be added to the catalog with the name "vault-plugin-auth-gcp". Run the following command to enable this new auth method as a plugin:
$ vault auth enable -plugin-name="vault-plugin-auth-gcp" -path="gcp" plugin Success! Enabled vault-plugin-auth-gcp plugin at: gcp/
This plugin has comprehensive acceptance tests covering most of the features of this auth backend.
If you are developing this plugin and want to verify it is still functioning (and you haven't broken anything else), we recommend running the acceptance tests.
Acceptance tests typically require other environment variables to be set for things such as access keys. The test itself should error early and tell you what to set, so it is not documented here.
Warning: The acceptance tests create/destroy/modify real resources, which may incur real costs in some cases. In the presence of a bug, it is technically possible that broken backends could leave dangling data behind. Therefore, please run the acceptance tests at your own risk. At the very least, we recommend running them in their own private account for whatever backend you're testing.
To run the acceptance tests, you will need a GCP IAM service account with project.viewer and serviceaccount.admin permission. You can generate one from the Google Cloud Console. Save this file locally and export its contents as an environment variable:
$ export GOOGLE_CREDENTIALS="$(cat my-credentials.sh)"
To run the acceptance tests, invoke
$ make test
You can also specify a
TESTARGS variable to filter tests like so:
$ make test TESTARGS='--run=TestConfig'