英文:
Referencing folder ID from module - google terraform folders module and project factor module
问题
我使用了terraform模块terraform-google-modules/folders/google和terraform-google-modules/project-factory/google,但我无法弄清楚如何引用一个我需要在项目工厂模块中使用的已创建文件夹。输出似乎也是IDS而不是一个ID。
我想引用共用文件夹ID,以便我创建的项目位于正确的文件夹层次结构中。
我阅读了大量的文档并尝试寻找示例,但我找到的关于文件夹的一切都是文件夹资源而不是文件夹模块。
// 设置GCP中的文件夹结构
module "folders" {
source = "terraform-google-modules/folders/google"
version = "~> 3.0"
parent = "folders/60860476666"
names = [
"development",
"staging",
"production",
"common",
]
set_roles = true
prefix = "fldr"
per_folder_admins = {
dev = "group:gcp-organization-admins@mydomain.me"
staging = "group:gcp-organization-admins@mydomain.me"
production = "group:gcp-organization-admins@mydomain.me"
}
all_folder_admins = [
"group:gcp-organization-admins@mydomain.me",
]
}
// 设置日志项目
module "project-factory-logging" {
source = "terraform-google-modules/project-factory/google"
version = "~> 14.0"
random_project_id = true
name = "shared-logging"
folder_id = module.folders.???? // 这里填写你需要引用的文件夹的ID
org_id = var.organization_id
billing_account = var.billing_account
default_service_account = "deprivilege"
}
请注意,在folder_id
字段中,你需要替换module.folders.????
部分为你想要引用的文件夹的ID。
英文:
I use the terraform modules terraform-google-modules/folders/google and terraform-google-modules/project-factory/google and I cannot figure out how to reference one created folder that I need to use in the project factory module. The output seems to be IDS as well not one ID
https://registry.terraform.io/modules/terraform-google-modules/project-factory/google/latest
https://registry.terraform.io/modules/terraform-google-modules/folders/google/latest
I would like to reference the common folder ID so the project I create sits in the right folder hierarchy.
I read plenty of documentation and tried to find examples but everything I find around folders is the folder resources not folder module.
// setup folder structure in gcp
module "folders" {
source = "terraform-google-modules/folders/google"
version = "~> 3.0"
parent = "folders/60860476666"
names = [
"development",
"staging",
"production",
"common",
]
set_roles = true
prefix = "fldr"
per_folder_admins = {
dev = "group:gcp-organization-admins@mydomain.me"
staging = "group:gcp-organization-admins@mydomain.me"
production = "group:gcp-organization-admins@mydomain.me"
}
all_folder_admins = [
"group:gcp-organization-admins@mydomain.me",
]
}
// setup logging project
module "project-factory-logging" {
source = "terraform-google-modules/project-factory/google"
version = "~> 14.0"
random_project_id = true
name = "shared-logging"
folder_id = module.folder**s.????**
org_id = var.organization_id
billing_account = var.billing_account
default_service_account = "deprivilege"
}
答案1
得分: 1
为了获取 common
文件夹,以下内容应该足够:
folder_id = module.folders.folders_map["common"].name
英文:
To get common
folder it, the following should be enough:
folder_id = module.folders.folders_map["common"].name
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论