Open joshbench opened 2 months ago
Hi @joshbench,
Thanks reporting this issue. Would you mind setting the value on the VaultAuth's .spec.aws.headerValue
, rather than in .spec.headers
. See https://developer.hashicorp.com/vault/docs/platform/k8s/vso/api-reference#vaultauthconfigaws for more info.
Please let us know if that helps to resolve the issue.
Thanks,
Ben
I @benashz,
Thank you for responding!
I reconfigured my values.yml like so:
---
controller:
manager:
extraEnv:
# Required for Pod Identity (https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html)
- name: AWS_SDK_LOAD_CONFIG
value: "'true'"
defaultVaultConnection:
enabled: true
address: "https://my.vault.address:8200"
tlsServerName: "my.vault.address"
defaultAuthMethod:
enabled: true
method: aws
mount: us-east-1/aws
aws:
role: my-role
region: us-east-1
headerValue: my.vault.address
And I'm still getting an error, but now it's "missing Authorization header":
{"level":"error","ts":"2024-09-13T18:27:09Z","logger":"cachingClientFactory","msg":"Failed to get NewClientWithLogin","controller":"vaultstaticsecret","controllerGroup":"secrets.hashicorp.com","controllerKind":"VaultStaticSecret","VaultStaticSecret":{"name":"example-secret","namespace":"my-app-namespace"},"namespace":"my-app-namespace","name":"example-secret","reconcileID":"8b72bed4-4bd3-4a37-82f7-ae91f4b8995a","cacheKey":"aws-6bd141d8ace9805f592ec3","error":"Error making API request.\n\nURL: PUT https://my.vault.address:8200/v1/auth/us-east-1/aws/login\nCode: 400. Errors:\n\n* error validating X-Vault-AWS-IAM-Server-ID header: missing Authorization header"}
Warning VaultClientConfigError 3m51s (x13 over 4m45s) VaultStaticSecret Failed to get Vault auth login: Error making API request.
URL: PUT https://my.vault.address:8200/v1/auth/us-east-1/aws/login Code: 400. Errors:
URL: PUT https://my.vault.address:8200/v1/auth/us-east-1/aws/login Code: 400. Errors:
Seems like the Authorization header is possibly getting overwritten?
Looking further into this, and also reading up on https://developer.hashicorp.com/vault/docs/auth/aws#iam-auth-method, I think I'm just not authenticating to AWS correctly, so the Authorization header is not being set. I think the version of the package used for AWS authentication uses an older version of the AWS SDK that doesn't support Pod Identity.
Where newer versions of awsutil seem to use aws-sdk-go-v2, which does support pod identity:
So maybe instead, this should be a feature request to support authentication via Pod Identity?
Describe the bug
When vault-secrets-operator is configured to authenticate to Vault with AWS IAM, with
X-Vault-AWS-IAM-Server-ID
set as a header in the VaultAuth custom resource, aVaultStaticSecret
that is configured to use the configuredVaultAuth
fails to authenticate with the following error:It seems like when the
VaultStaticSecret
attempts to refresh, or to authenticate before refreshing, it is not attempting to use this header.To Reproduce Steps to reproduce the behavior:
defaultVaultConnection: enabled: true address: "https://my.vault.address:8200" tlsServerName: "my.vault.address" headers: X-Vault-AWS-IAM-Server-ID: "my.vault.address"
defaultAuthMethod: enabled: true method: aws mount: us-east-1/aws aws: role: my-role region: us-east-1 headers: X-Vault-AWS-IAM-Server-ID: "my.vault.address"
apiVersion: secrets.hashicorp.com/v1beta1 kind: VaultStaticSecret metadata: name: example-secret namespace: my-app-namespace spec: type: kv-v2 mount: secretmount path: my/secret/path destination: name: example-secret create: true overwrite: true refreshAfter: 1h
Name: example-secret Namespace: my-app-namespace Labels:
Annotations:
API Version: secrets.hashicorp.com/v1beta1
Kind: VaultStaticSecret
Metadata:
Creation Timestamp: 2024-09-12T19:52:52Z
Generation: 1
Resource Version: 56303
UID: c2470e10-ac7e-427e-a269-ffa2d031ba8f
Spec:
Destination:
Create: true
Name: example-secret
Overwrite: true
Hmac Secret Data: true
Mount: secretmount
Path: my/secret/path
Refresh After: 1h
Type: kv-v2
Events:
Type Reason Age From Message
Warning VaultClientConfigError 4m6s (x203 over 19m) VaultStaticSecret Failed to get Vault auth login: Error making API request.
URL: PUT https://my.vault.address:8200/v1/auth/us-east-1/aws/login Code: 400. Errors:
error validating X-Vault-AWS-IAM-Server-ID header: missing header "X-Vault-AWS-IAM-Server-ID"
kubectl describe vaultauth default
Relevant logs:
Expected behavior
Environment
Additional context Add any other context about the problem here.