Skip to content

Commit

Permalink
feature: add worker_filter option to Boundary Credential Store Vault (#…
Browse files Browse the repository at this point in the history
…375)

* feature: add worker_filter option to Boundary Credential Store Vault

* Update changelog
  • Loading branch information
mikemountain authored Apr 20, 2023
1 parent 1631419 commit 0d42299
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 0d42299

Please sign in to comment.