AWS Secrets Manager - How to get secret and use it in a template #1404
-
Hello, We are starting to use gomplate with data stored in AWS Secrets Manager, but looks that we need more information how to use it. We have a secret Create secret aws secretsmanager create-secret \
--name test \
--secret-string "{\"key1_name\":\"key1_value\",\"key2_name\":\"key2_value\"}" aws cli aws secretsmanager get-secret-value --secret-id test | jq -r .SecretString
{"key1_name":"key1_value","key2_name":"key2_value"} gomplate echo '{{ (ds "test") }}' | gomplate -d test=aws+sm:test
11:05:31 ERR error="failed to render template -: template: -:1:4: executing \"-\" at <ds \"test\">: error calling ds: Couldn't read datasource 'test': Error reading aws+sm from AWS using GetSecretValue with input {\n SecretId: \"test\"\n}: RequestError: send request failed\ncaused by: Post \"https://secretsmanager.us-east-1.amazonaws.com/\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @air3ijai, First off, the error you're getting looks like #1234. Try setting the
Looks like that doc section is missing a link to https://docs.gomplate.ca/functions/aws/#configuring-aws - it's linked from the
I'm not sure I totally understand this question - are you referring to the
The first approach is obviously much simpler. And, if you use the context instead, it can be even simpler (
I'm not entirely sure I understand this question either, but if I was correct in my assumption above, that should answer this too... |
Beta Was this translation helpful? Give feedback.
-
@hairyhenderson, thank you for the hints - now it is more clear. Variable solved the issue with the timeout: # Timeout
export AWS_TIMEOUT=2000
# Authentication
export AWS_REGION=us-east-1
export AWS_PROFILE=staging
echo '{{ (data.JSON (ds "test")).key1_name }}' | gomplate -d test=aws+sm:test
key1_value And we can get value from the JSON and refer in the template to the both keys using a single datasource cat test.yaml
Test AWS Secrets: {{ (ds "test").key1_name }} - {{ (ds "test").key2_name }} gomplate -d 'test=aws+sm:test?type=application/json' -f test.yaml
Test AWS Secrets: key1_value - key2_value |
Beta Was this translation helpful? Give feedback.
Hi @air3ijai,
First off, the error you're getting looks like #1234. Try setting the
AWS_TIMEOUT
environment variable to a value like2000
(milliseconds) to see if that works around the issue.Looks like that doc section is missing a link to https://docs.gomplate.ca/functions/aws/#configuring-aws - it's linked from the
aws+smp
docs, but I must've missedaws+sm
!I'm not sure I totally understand this question - are you referring to the
key1_name
JSON field names encoded in the secret's value? If so, there are two…