所以我有一组大约 30 个输入,在所有项目之间共享。我想知道在所有 terragrunt.hcl 文件中共享它们的最佳方法,而不必将它们复制到一百万个不同的地方。我目前使用 yaml 文件进行一些覆盖。我想知道最佳实践是什么。
locals {
manager = "devops" # default contact
company_id = "moos3" # any string to identify the company for better resources naming. Keep max size of five chars.
default_yaml_path = find_in_parent_folders("empty.yaml") # terragrunt function. read the file content for better explanation.
enabled_api_services = [ # APIs enabled by default for all projects when created
"compute.googleapis.com",
"cloudkms.googleapis.com",
"cloudresourcemanager.googleapis.com",
"logging.googleapis.com",
"monitoring.googleapis.com",
"serviceusage.googleapis.com",
"storage-api.googleapis.com",
]
gcp_billing_account = "*****************" # gcp billing account where projects will be created
gcp_org_id = "*****************" # gcp organization id where resources will be created
gcp_seed_project_id = "my-seed" # initial seed project where terraform state bucket will be created
region = "us-east1" # default region for shared services
stack = "global" # architectural stack name
}
Run Code Online (Sandbox Code Playgroud)
如果只包含一个模块来包含这些内容或从集中路径加载它们,那就太好了。因为这些东西不会经常改变。
小智 4
目前 Terragrunt 的最佳实践是使用该read_terragrunt_config函数将变量导入到子配置中以供重用。
请参阅repo中mysql 的子 terragrunt.hcl。请注意我们如何导入环境名称并将其插入到输入中。您还可以使用 直接合并变量以作为输入向前传递。terragrunt-infrastructure-live-exampleread_terragrunt_configinputs = merge(local.environment_vars.locals, { /* additional inputs here */ })
| 归档时间: |
|
| 查看次数: |
5350 次 |
| 最近记录: |