JSON file:https://1drv.ms/u/s!AizscpxS0QM4hJl_VRQaWbm6D8T8_w
This is one section:
"RoleDetailList": [
{
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRoleWithSAML",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
},
"Principal": {
"Federated": "arn:aws:iam::279052847476:saml-provider/CompanyADFS"
}
}
]
},
"RoleId": "AROAJANL3L2IZ6UISEGAU",
"CreateDate": "2016-08-20T13:51:07Z",
"InstanceProfileList": [],
"RoleName": "ADFS-Administrators",
"Path": "/",
"AttachedManagedPolicies": [],
"RolePolicyList": [
{
"PolicyName": "Administrator-Access",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "*",
"Resource": "*",
"Effect": "Allow",
"Sid": "Stmt1434192117145"
}
]
}
}
],
"Arn": "arn:aws:iam::279052847476:role/ADFS-Administrators"
},
How,for all these sections in JSON file to get following (this is example for this section only) to CSV format ?
Desired output:
sts:AssumeRoleWithSAML,arn:aws:iam::279052847476:saml-provider/CompanyADFS",ADFS-Administrators,Administrator-Access
So far i have this:
jq -r '.RoleDetailList | map(select((.AssumeRolePolicyDocument.Statement | length > 0) and (.AssumeRolePolicyDocument.Statement[].Principal.Federated) and (.RolePolicyList | length > 0)) )[] | [(.AssumeRolePolicyDocument.Statement[] | .Action, .Principal.Federated),.RoleName, .RolePolicyList[].PolicyName] | @csv' output.json
"ADFS-Administrators","Administrator-Access"
But it doesn’t show other values, only first one