I am trying to get a secret value to a var from AWS Secret Manager using Ansible. My original attempt was as follows:
mySecret: "{{ lookup('amazon.aws.aws_secret', 'my/awesome/secret', region='eu-west-2')}}"
This returns a value like:
{"password" : "mypassword"}
All I want is the mypassword
value
I have tried numerous ways using json_query
including:
mySecret: "{{ lookup('amazon.aws.aws_secret', 'my/awesome/secret', region='eu-west-2') | from_json | json_query('SecretString.password') }}"
But this does not return a value.
What is the correct way of extracting the value only when using json_query with Ansible?