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: add worker_filter option to Boundary Credential Store Vault #375

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Canonical reference for changes, improvements, and bugfixes for the Boundary Ter

## Next

### New and Improved
* Add support for credential store vault worker filters ([PR](https://github.com/hashicorp/terraform-provider-boundary/pull/375))

### Bug Fix
* Allow users to set OIDC maxAge value to 0 to require immediate reauth ([PR](https://github.com/hashicorp/terraform-provider-boundary/pull/364))

Expand Down
20 changes: 20 additions & 0 deletions internal/provider/resource_credential_store_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
credentialStoreVaultClientCertificateKeyKey = "client_certificate_key"
credentialStoreVaultClientCertificateKeyHmacKey = "client_certificate_key_hmac"
credentialStoreType = "vault"
credentialStoreVaultWorkerFilterKey = "worker_filter"
)

var storeVaultAttrs = []string{
Expand Down Expand Up @@ -123,6 +124,11 @@ func resourceCredentialStoreVault() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
credentialStoreVaultWorkerFilterKey: {
Description: "HCP Only. A filter used to control which PKI workers can handle Vault requests. This allows the use of private Vault instances with Boundary.",
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand All @@ -137,6 +143,9 @@ func setFromVaultCredentialStoreResponseMap(d *schema.ResourceData, raw map[stri
if err := d.Set(ScopeIdKey, raw[ScopeIdKey]); err != nil {
return diag.FromErr(err)
}
if err := d.Set(credentialStoreVaultWorkerFilterKey, raw[credentialStoreVaultWorkerFilterKey]); err != nil {
return diag.FromErr(err)
}

var diags diag.Diagnostics
csId := raw["id"]
Expand Down Expand Up @@ -228,6 +237,9 @@ func resourceCredentialStoreVaultCreate(ctx context.Context, d *schema.ResourceD
if v, ok := d.GetOk(credentialStoreVaultTokenKey); ok {
opts = append(opts, credentialstores.WithVaultCredentialStoreToken(v.(string)))
}
if v, ok := d.GetOk(credentialStoreVaultWorkerFilterKey); ok {
opts = append(opts, credentialstores.WithVaultCredentialStoreWorkerFilter(v.(string)))
}

var scope string
gotScope, ok := d.GetOk(ScopeIdKey)
Expand Down Expand Up @@ -359,6 +371,14 @@ func resourceCredentialStoreVaultUpdate(ctx context.Context, d *schema.ResourceD
}
}

if d.HasChange(credentialStoreVaultWorkerFilterKey) {
opts = append(opts, credentialstores.DefaultVaultCredentialStoreWorkerFilter())
v, ok := d.GetOk(credentialStoreVaultWorkerFilterKey)
if ok {
opts = append(opts, credentialstores.WithVaultCredentialStoreWorkerFilter(v.(string)))
}
}

if len(opts) > 0 {
opts = append(opts, credentialstores.WithAutomaticVersioning(true))
crUpdate, err := client.Update(ctx, d.Id(), 0, opts...)
Expand Down