From c9d5a8ecd6abf18023bae9d2445b39ded838b487 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Fri, 19 Apr 2024 10:19:34 -0500 Subject: [PATCH] update data source and docs --- vault/data_source_kubernetes_auth_backend_config.go | 10 ++++++++++ .../data_source_kubernetes_auth_backend_config_test.go | 5 +++++ website/docs/d/kubernetes_auth_backend_config.md | 6 ++++++ website/docs/r/kubernetes_auth_backend_config.md | 2 ++ 4 files changed, 23 insertions(+) diff --git a/vault/data_source_kubernetes_auth_backend_config.go b/vault/data_source_kubernetes_auth_backend_config.go index 9f67f34db8..0c6632111b 100644 --- a/vault/data_source_kubernetes_auth_backend_config.go +++ b/vault/data_source_kubernetes_auth_backend_config.go @@ -66,6 +66,12 @@ func kubernetesAuthBackendConfigDataSource() *schema.Resource { Optional: true, Description: "Optional disable defaulting to the local CA cert and service account JWT when running in a Kubernetes pod.", }, + fieldUseAnnotationsAsAliasMetadata: { + Type: schema.TypeBool, + Computed: true, + Optional: true, + Description: "Use annotations from the client token's associated service account as alias metadata for the Vault entity.", + }, }, } } @@ -105,5 +111,9 @@ func kubernetesAuthBackendConfigDataSourceRead(d *schema.ResourceData, meta inte d.Set(consts.FieldDisableISSValidation, resp.Data[consts.FieldDisableISSValidation]) d.Set(consts.FieldDisableLocalCAJWT, resp.Data[consts.FieldDisableLocalCAJWT]) + if provider.IsAPISupported(meta, provider.VaultVersion116) { + d.Set(fieldUseAnnotationsAsAliasMetadata, resp.Data[fieldUseAnnotationsAsAliasMetadata]) + } + return nil } diff --git a/vault/data_source_kubernetes_auth_backend_config_test.go b/vault/data_source_kubernetes_auth_backend_config_test.go index 216e77b5f2..0658873f8c 100644 --- a/vault/data_source_kubernetes_auth_backend_config_test.go +++ b/vault/data_source_kubernetes_auth_backend_config_test.go @@ -62,6 +62,7 @@ func TestAccKubernetesAuthBackendConfigDataSource_full(t *testing.T) { issuer := "kubernetes/serviceaccount" disableIssValidation := true disableLocalCaJwt := true + useAnnotationsAsAliasMetadata := true resource.Test(t, resource.TestCase{ PreCheck: func() { testutil.TestAccPreCheck(t) }, @@ -90,6 +91,8 @@ func TestAccKubernetesAuthBackendConfigDataSource_full(t *testing.T) { consts.FieldDisableISSValidation, strconv.FormatBool(disableIssValidation)), resource.TestCheckResourceAttr("vault_kubernetes_auth_backend_config.config", consts.FieldDisableLocalCAJWT, strconv.FormatBool(disableLocalCaJwt)), + resource.TestCheckResourceAttr("vault_kubernetes_auth_backend_config.config", + fieldUseAnnotationsAsAliasMetadata, strconv.FormatBool(useAnnotationsAsAliasMetadata)), ), }, { @@ -113,6 +116,8 @@ func TestAccKubernetesAuthBackendConfigDataSource_full(t *testing.T) { consts.FieldDisableISSValidation, strconv.FormatBool(disableIssValidation)), resource.TestCheckResourceAttr("vault_kubernetes_auth_backend_config.config", consts.FieldDisableLocalCAJWT, strconv.FormatBool(disableLocalCaJwt)), + resource.TestCheckResourceAttr("vault_kubernetes_auth_backend_config.config", + fieldUseAnnotationsAsAliasMetadata, strconv.FormatBool(useAnnotationsAsAliasMetadata)), ), }, }, diff --git a/website/docs/d/kubernetes_auth_backend_config.md b/website/docs/d/kubernetes_auth_backend_config.md index 1e3761b1ed..698614b9dc 100644 --- a/website/docs/d/kubernetes_auth_backend_config.md +++ b/website/docs/d/kubernetes_auth_backend_config.md @@ -47,3 +47,9 @@ In addition to the above arguments, the following attributes are exported: * `pem_keys` - Optional list of PEM-formatted public keys or certificates used to verify the signatures of Kubernetes service account JWTs. If a certificate is given, its public key will be extracted. Not every installation of Kubernetes exposes these keys. * `issuer` - Optional JWT issuer. If no issuer is specified, `kubernetes.io/serviceaccount` will be used as the default issuer. + +* `disable_iss_validation` - (Optional) Disable JWT issuer validation. Allows to skip ISS validation. Requires Vault `v1.5.4+` or Vault auth kubernetes plugin `v0.7.1+` + +* `disable_local_ca_jwt` - (Optional) Disable defaulting to the local CA cert and service account JWT when running in a Kubernetes pod. Requires Vault `v1.5.4+` or Vault auth kubernetes plugin `v0.7.1+` + +* `use_annotations_as_alias_metadata` - (Optional) Use annotations from the client token's associated service account as alias metadata for the Vault entity. Requires Vault `v1.16+` or Vault auth kubernetes plugin `v0.18.0+` diff --git a/website/docs/r/kubernetes_auth_backend_config.md b/website/docs/r/kubernetes_auth_backend_config.md index 4b8c84fa25..590a7505cd 100644 --- a/website/docs/r/kubernetes_auth_backend_config.md +++ b/website/docs/r/kubernetes_auth_backend_config.md @@ -52,6 +52,8 @@ The following arguments are supported: * `disable_local_ca_jwt` - (Optional) Disable defaulting to the local CA cert and service account JWT when running in a Kubernetes pod. Requires Vault `v1.5.4+` or Vault auth kubernetes plugin `v0.7.1+` +* `use_annotations_as_alias_metadata` - (Optional) Use annotations from the client token's associated service account as alias metadata for the Vault entity. Requires Vault `v1.16+` or Vault auth kubernetes plugin `v0.18.0+` + ## Attributes Reference