#bash (2021-04)
A channel for bash scripting
2021-04-12
does anyone know how to convert a list (output from awscli) into JSON with key:value?
doesnt --output json
help from aws-cli ?
comma-separated list, or rows?
aws <cmd>
a,b,c
# or
aws s3 ls
a
b
c
I’m trying to achieve this btw https://sweetops.slack.com/archives/CB6GHNLG0/p1618336796004900
Hi all, I’m trying to dynamically obtain the ARNS of aws resource share invitations. I found that the data source for RAM doesn’t really support this. I’m attempting to mimic this example instead and I’ve been able to retrieve the ARNS using the following awscli command below:
aws ram get-resource-share-invitations \
--query 'resourceShareInvitations[*]|[?contains(resourceShareName,`prefix`)==`true`].resourceShareInvitationArn' \
--region us-east-1
However, I’m not sure how I can get it into the correct format that data.external
requires. Ideally Id want the output to be:
{ resrouceShareName: resourceShareInvitationArn }
I think I’ve almost got it, with the following code
invitations=$(aws ram get-resource-share-invitations \
--query 'resourceShareInvitations[*]|[?contains(resourceShareName,`prefix`)==`true`].[resourceShareName,resourceShareInvitationArn]' \
--region us-east-1)
jq -c '.[0] as $keys | .[1] as $values | reduce range(0; $keys|length) as $i ( {}; . + { ($keys[$i]): $values[$i] })' <<< $invitations
I get the names together and the arns together, not sure whats wrong