![](/img/trans.png)
[英]create service account and assign permissions/roles at the organization level in GCP
[英]Get list of assets/resource for a given project in GCP without any organization level permissions
我一直在探索的一個選項如下。
在閱讀文檔https://cloud.google.com/security-command-center/docs/how-to-api-list-assets#listing_all_assets時,發現我們可以使用 Security Command Center API 獲取所有資產的列表。
以下是文檔中提供的代碼。
static ImmutableList<ListAssetsResult> listAssets(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request for to search for all assets in an organization.
// OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");
ListAssetsRequest.Builder request =
ListAssetsRequest.newBuilder().setParent(organizationName.toString());
// Call the API.
ListAssetsPagedResponse response = client.listAssets(request.build());
// This creates one list for all assets. If your organization has a large number of assets
// this can cause out of memory issues. You can process them incrementally by returning
// the Iterable returned response.iterateAll() directly.
ImmutableList<ListAssetsResult> results = ImmutableList.copyOf(response.iterateAll());
System.out.println("All assets:");
System.out.println(results);
return results;
} catch (IOException e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
在安全命令中心運行命令會返回錯誤“PERMISSION_DENIED:對資源‘organizations/{organization-id}’(或資源可能不存在)的權限‘securitycenter.assets.list’被拒絕”作為響應。
根據以下文檔https://cloud.google.com/security-command-center/docs/access-control ,需要在組織級別設置權限“securitycenter.assets.list”,這是有問題的。
我正在尋找一個選項來繞過上述問題,我不需要組織級別的許可或任何其他 API 這將幫助我完成這項工作。
要使用 Security Command Center,您的項目需要成為組織的一部分。 您還需要組織級別的權限。 您的目標無法在項目級別實現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.