Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

Parsing nested json with jq - Cannot index string [duplicate]

$
0
0

I cannot work out what is happening here.

I am using Amazon Secret Manager in a ec2 user_data bash script to retrieve a secret to be used on ec2 bootup.

SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id *** --region **** --output json | jq)

This returns the full response

{"ARN": "arn:aws:secretsmanager:***:****:secret:***","Name": "***","VersionId": "***","SecretString": "{\"password\":\"********************\"}","VersionStages": ["AWSCURRENT"  ],"CreatedDate": "2025-**-**T**:**:**.****+**:**"}
SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id *** --region **** --output json | jq -r '.SecretString')

Gets me closer

{"password":"***"}

Looking at previous stackoverflows I've tried the following:

SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id *** --region **** --output json | jq -r '.SecretString | .password')

jq: error (at <stdin>:10): Cannot index string with string "password"

SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id *** --region **** --output json | jq -r '.SecretString.password')

jq: error (at <stdin>:10): Cannot index string with string "password"

What am I doing wrong?


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>