組織ドメイン:AAA プロジェクト:X フォルダ:111 フォルダ:222 プロジェクト:Y プロジェクト:Z Google Gourp: 1XY user: c service account: cc Google Gourp: 2Z service account: d Google Gourp: ADMIN
identity groups を利用してデータを取得して BigQueryに格納して、クエリで比較しました。 WITH all_jp_data as ( select user, group_name from [移行元のgroup情報が格納されたテーブル名]), inc AS (select user, group_name from [移行先のgroup情報が格納されたテーブル名]), a_intersect_inc AS (SELECT * FROM a INTERSECT DISTINCT SELECT * FROM inc ), a_except_inc AS (SELECT * FROM a EXCEPT DISTINCT SELECT * FROM inc ), inc_except_a AS (SELECT * FROM inc EXCEPT DISTINCT SELECT * FROM a ), all_records AS ( SELECT *, TRUE AS in_a, TRUE AS in_inc FROM a_intersect_inc UNION ALL SELECT *, TRUE AS in_a, FALSE AS in_inc FROM a_except_inc UNION ALL SELECT *, FALSE AS in_a, TRUE AS in_inc FROM inc_except_a ) select * from all_records #!bin/bash IFS=$'\n'; for group in `gcloud identity groups search --organization="[組織ID]" --labels="cloudidentity.googleapis.com/groups.discussion_forum" --format=json | jq -r '.groups | .[].groupKey.id'`; do gcloud identity groups memberships list --group-email="$group" --format=json | jq --arg Group_value $group -r -c '.[] | {group_name: $Group_value, user: .preferredMemberKey.id, id: .name}' >> tmp_group.jsonl done bq --location=asia-northeast1 load \ --autodetect=true \ --replace=true \ --source_format=NEWLINE_DELIMITED_JSON \ [格納先テーブル名] \ ./tmp_group.jsonl 組織に紐づく Google Groupと 所属するアカウント を取得用shell Google Groupを 比較するためのクエリ
SELECT name, members,role, FROM [移行元のcloud asset inventoryのiam policy] r CROSS JOIN UNNEST(r.iam_policy.bindings) as binding CROSS JOIN UNNEST(binding.members) as members WHERE asset_type="cloudresourcemanager.googleapis.com/Folder" and binding.role is not null and members not like ("user%") and name in ([フォルダの指定]) ), 移行先 as ( SELECT name, members, role, FROM [移行先のcloud asset inventoryのiam policy] r CROSS JOIN UNNEST(r.iam_policy.bindings) as binding CROSS JOIN UNNEST(binding.members) as members where asset_type="cloudresourcemanager.googleapis.com/Folder" and members not like ("user%") and binding.role is not null and name in ([フォルダの指定]) ), 移行元_intersect_移行先 AS (SELECT * FROM a INTERSECT DISTINCT SELECT * FROM 移行先 ), 移行元_except_移行先 AS (SELECT * FROM a EXCEPT DISTINCT SELECT * FROM 移行先 ), 移行先_except_移行元 AS (SELECT * FROM 移行先 EXCEPT DISTINCT SELECT * FROM a ), all_records AS ( SELECT *, TRUE AS in_移行元, TRUE AS in_移行先 FROM 移行元_intersect_移行先 UNION ALL SELECT *, TRUE AS in_移行元, FALSE AS in_移行先 FROM 移行元_except_移行先 UNION ALL SELECT*, FALSE AS in_移行元, TRUE AS in_移行先 FROM 移行先_except_移行元 ), select * from all_records order by 1 Cloud Asset Inventoryで 取得したIAM Policyの 比較クエリ *フォルダ間の確認 ◆注意 組織ドメインが違うので、 case文とかで少し修正が必要です。
クト:X フォルダ :111 フォルダ :222 プロジェ クト:Y プロジェ クト:Z Google Gourp: 1XY user: c service accoun t: cc Google Gourp: 2Z service accoun t: d Google Gourp: ADMIN 組織ドメイ ン:BBB プロジェク ト:X フォルダ :111 フォルダ :222 プロジェク ト:Y プロジェク ト:Z Google Gourp: 1XY user: c service account: cc Google Gourp: 2Z service account: d Google Gourp: ADMIN