Hello!
I’m trying to migrate kubernetes configmaps to secrets in Vault. I need them as environment variables (Symfony project).
I’m using vault agent injector and annotations in kubernetes (deployment).
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/role: 'beta'
vault.hashicorp.com/agent-init-first: 'true'
vault.hashicorp.com/agent-inject-status: 'update'
vault.hashicorp.com/agent-inject-template-beta-backend-export.properties: |
{{- with secret "beta-backend/beta-test-it" -}}
{{- range $k, $v := .Data.data }}
export {{$k}}='{{$v}}'
{{- end -}}
{{ end }}
vault.hashicorp.com/agent-inject-secret-credentials.txt: 'beta-backend/data/beta-test-it'
- in deployment:
cat /vault/secrets/beta-backend-export.properties >> $HOME/.bashrc
source $HOME/.bashrc
I faced problem with JSON env. Let’s say I have env like this:
TEST_ENV='{"it_IT":{"publicKey": "103434-45645643","privateKey":"24bc564c68673c6e340c7aa1f"}}'
Vault agent injector is creating the file and inside I have it with double quotes so like JSON should looks like, but doing source
my env is missing double qouotes and looks like:
TEST_ENV='{it_IT:{publicKey: 103434-45645643,privateKey:24bc564c68673c6e340c7aa1f}}'
Is there any option to prevent this? I was thinking about escaping all double quotes in annotation, where export name is injecting? Is it possible?
To get something like:
TEST_ENV='{\"it_IT\":{\"publicKey\": \"10343445645643\",\"privateKey\":\"24bc564c68673c6e340c7aa1f\"}}'