我想知道我当前在 GCP 中的项目的组织 ID。
gcloud projects describe PROJECT_ID将显示parent可以是组织,但如果父级是folder,则不会显示组织 ID。
我可以使用 递归文件夹的父层次结构gcloud resource-manager folders describe FOLDER_ID,但这很麻烦。如果我没有组织级别的权限也是不可能的。
但我确实可以访问组织 ID:gcloud organizations list显示多个组织,但不能映射到项目。
我怎样才能实现这个目标?
在 Google Cloud Platform (GCP) 中,您可以使用列表 API 或命令列出给定项目中给定服务中给定类型的资源,例如 BigQuery 数据集或计算实例。
但如何跨类型、服务甚至项目查找或搜索资源呢?
google-bigquery google-compute-engine google-cloud-platform gcloud google-cloud-resource-manager
在 Google Cloud Platform (GCP) 中,您只能通过调用 getIamPolicy(gcloud 中的 get-iam-policy)获取特定资源的 IAM 策略。
是否可以列出、搜索、列出、搜索或查找跨资源、服务或项目的 IAM 策略?
这是回答以下问题所必需的:
google-cloud-platform gcloud google-iam google-cloud-iam google-cloud-resource-manager
我正在尝试通过谷歌云功能的资源管理器 API 以编程方式创建项目,如下所示:
exports.createProjectAsync = async (projectId, projectName) => {
const scopes = "https://www.googleapis.com/auth/cloud-platform"
const url = `http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?scopes=${scopes}`
const tokenResult = await fetch(url, {
headers: {
"Metadata-Flavor": "Google"
},
});
const tokenStatus = tokenResult.status;
functions.logger.log(`Call to get token has status ${tokenStatus}`);
const tokenData = await tokenResult.json()
functions.logger.log(`Call to get token has data ${JSON.stringify(tokenData)}`);
const accessToken = tokenData.access_token;
if (accessToken === null) {
throw new Error(`Failed to retrieve access token`);
}
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
}; …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-functions google-cloud-resource-manager