затрудняется преобразовать json в csv с помощью команды jq
{
"ResourceTagMappingList": [
{
"ResourceARN": "arn:aws:ec2:us-east-1:027906322765228:customer-gateway/cgw-e404f4440d",
"Tags": [
{
"Value": "useast-prod-vpn01-cisco",
"Key": "Name"
}
]
},
{
"ResourceARN": "arn:aws:ec2:us-east-1:017906322765228:customer-gateway/cgw-e7a447508555e",
"Tags": [
{
"Value": "useast-prod-vpn02-cisco",
"Key": "Name"
}
]
},
{
"ResourceARN": "arn:aws:ec2:us-east-1:5079063766562328:customer-gateway/cgw-e7a44754408e"
},
{
"ResourceARN": "arn:aws:ec2:us-east-1:07945406375465228:image/ami-012446b78ea15546fbd",
"Tags": [
{
"Value": "processor-USE-img-18022019",
"Key": "Name"
}
]
},
{
"ResourceARN": "arn:aws:ec2:us-east-1:079063765434343228:image/ami-0624f58fdf53eacd3775",
"Tags": [
{
"Value": "DevOpsUSE1",
"Key": "AppCluster"
},
{
"Value": "Image",
"Key": "AppEnv"
},
{
"Value": "Image",
"Key": "AppGroup"
}
]
},
{
"ResourceARN": "arn:aws:ec2:us-east-1:079063765228:instance/i-0087f44110c478d49",
"Tags": [
{
"Value": "Inst01USE1",
"Key": "App01"
},
{
"Value": "Production",
"Key": "AppEnv"
},
{
"Value": "usev-app01-ond-asg01",
"Key": "aws:autoscaling:groupName"
},
{
"Value": "lt-0ec354ad560e508cc",
"Key": "aws:ec2launchtemplate:id"
},
{
"Value": "8",
"Key": "aws:ec2launchtemplate:version"
}
]
}
]
}
вывод, ожидающий получения:
"ResourceARN","Name","AppCluster","AppEnv","AppGroup","App01","aws:autoscaling:groupName","aws:ec2launchtemplate:id","aws:ec2launchtemplate:version"
"arn:aws:ec2:us-east-1:027906322765228:customer-gateway/cgw-e404f4440d","useast-prod-vpn01-cisco",null,null,null,null,null,null,null
"arn:aws:ec2:us-east-1:017906322765228:customer-gateway/cgw-e7a447508555e","useast-prod-vpn02-cisco",null,null,null,null,null,null,null
"arn:aws:ec2:us-east-1:5079063766562328:customer-gateway/cgw-e7a44754408e",null,null,null,null,null,null,null,null
"arn:aws:ec2:us-east-1:07945406375465228:image/ami-012446b78ea15546fbd","processor-USE-img-18022019",null,null,null,null,null,null,null
"arn:aws:ec2:us-east-1:079063765434343228:image/ami-0624f58fdf53eacd3775",null,"DevOpsUSE1","Image","Image",null,null,null,null
"arn:aws:ec2:us-east-1:079550666376445228:instance/i-0087f44110c478d49",null,null,"Production",null,"Inst01USE1","usev-app01-ond-asg01","lt-0ec354ad560e508cc","8"
Что-то, что я пытался, но не смог достичь:
cat resourcesfile.json | jq -rc '.ResourceTagMappingList[]|{ResourceARN,tags: [ .["Tags"][]["Value"] ]}|.[]'
cat resourcesfile.json | jq -r '[[.ResourceTagMappingList[]|[{ResourceARN},(.Tags|from_entries)]|add]|.[]|to_entries|.[]|.key]|unique'
cat resourcesfile.json | jq -r '[.ResourceTagMappingList[]|[[{ResourceARN},(.Tags|from_entries)]|add]|.[]|to_entries|.[]|.key]|unique as $fields | ($fields | @csv)'
Заранее благодарим за любую помощь.