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

Feature request for issue #858 #861

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions vault/resource_gcp_auth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func gcpAuthBackendResource() *schema.Resource {
return strings.Trim(v.(string), "/")
},
},
"local": {
Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Description: "Specifies if the auth method is local only",
},
},
}
}
Expand Down Expand Up @@ -107,9 +113,14 @@ func gcpAuthBackendWrite(d *schema.ResourceData, meta interface{}) error {
authType := gcpAuthType
path := d.Get("path").(string)
desc := d.Get("description").(string)
local := d.Get("local").(bool)

log.Printf("[DEBUG] Enabling gcp auth backend %q", path)
err := client.Sys().EnableAuth(path, authType, desc)
err := client.Sys().EnableAuthWithOptions(path, &api.EnableAuthOptions{
Type: authType,
Description: desc,
Local: local,
})
if err != nil {
return fmt.Errorf("error enabling gcp auth backend %q: %s", path, err)
}
Expand Down Expand Up @@ -163,7 +174,7 @@ func gcpAuthBackendRead(d *schema.ResourceData, meta interface{}) error {
d.Set("client_id", resp.Data["client_id"])
d.Set("project_id", resp.Data["project_id"])
d.Set("client_email", resp.Data["client_email"])

d.Set("local", resp.Data["local"])
return nil
}

Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/gcp_auth_backend.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ The following arguments are supported:

* `credentials` - A JSON string containing the contents of a GCP credentials file. If this value is empty, Vault will try to use Application Default Credentials from the machine on which the Vault server is running.

* `path` - (Optional) The path to mount the auth method — this defaults to 'gcp'.

* `description` - (Optional) A description of the auth method.

* `local` - (Optional) Specifies if the auth method is local only.

For more details on the usage of each argument consult the [Vault GCP API documentation](https://www.vaultproject.io/api-docs/auth/gcp#configure).

## Attribute Reference
Expand Down