Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can I list all resources plus members, roles and assettypes as a CSV?

Hi, to better manage our infrastructure we'd like to set up a CSV report to list all resources in our projects and which members and roles have access to them.

I know I can create a CSV list with all members and roles within a project with the following command:

gcloud asset search-all-iam-policies --scope=projects/my-project --flatten='policy.bindings' --format='csv(policy.bindings.members, policy.bindings.role)'

However my question is, how can I add the corresponding resource and assettype to each line?

Thanks

Solved Solved
0 1 2,453
1 ACCEPTED SOLUTION

After poking a bit around it looks like I found the solution myself. The following command provides the output I was looking for:

gcloud asset search-all-iam-policies --scope=projects/my-project --flatten='policy.bindings[].members[]' --format='csv(resource, assetType, policy.bindings.members, policy.bindings.role)'

View solution in original post

1 REPLY 1

After poking a bit around it looks like I found the solution myself. The following command provides the output I was looking for:

gcloud asset search-all-iam-policies --scope=projects/my-project --flatten='policy.bindings[].members[]' --format='csv(resource, assetType, policy.bindings.members, policy.bindings.role)'