I am trying to create a terragrunt structure (I am a bit of a newbie) for a few "apps", here is how my structure looks like:
├── apps
│ ├── app3
│ │ ├── dev
│ │ │ ├── backend.tf
│ │ │ ├── provider.tf
│ │ │ └── terragrunt.hcl
│ │ └── terragrunt.hcl
│ ├── core-api
│ │ ├── dev
│ │ │ ├── backend.tf
│ │ │ ├── provider.tf
│ │ │ └── terragrunt.hcl
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
├── envrc
└── terragrunt-configs
├── config.hcl
└── envs
├── default.yaml
├── dev
│ └── default.yaml
└── staging
└── default.yaml
I run terragrunt from each app/env folder, for instance apps/app3/dev. Now, on one app terragrun I need to define a value that is to be used by another file. I say value, because I do not mind if this is a valiable, locals or other things.
Here is how my base file looks like in apps/app3/dev/terragrunt.hcl
:
include "config" {
path = find_in_parent_folders("/terragrunt-configs/config.hcl")
}
include "thisappcommon" {
path = "../terragrunt.hcl"
merge_strategy = "deep"
}
include "allappscommon" {
path = "../../terragrunt.hcl"
merge_strategy = "deep"
}
inputs = {
datadog_monitors = {}
}
我试图在这里增加一个当地人,而我却想使用其他东西。 页: 1 然后从另一个档案中将其称为apps/terragrunt.hcl/code>:
terraform {
source = "git::[email protected]:some-repo//monitors"
}
locals {
env_dir = "${basename(path_relative_to_include())}"
location_dir = "${basename(dirname(path_relative_to_include()))}"
extra_atlantis_dependencies = [
"${get_parent_terragrunt_dir()}/../terragrunt-configs/envs/default.yaml",
"${get_parent_terragrunt_dir()}/../terragrunt-configs/envs/${local.env_dir}/default.yaml",
]
env_vars = merge(
yamldecode(file(local.extra_atlantis_dependencies[0])),
yamldecode(file(local.extra_atlantis_dependencies[1])),
)
}
inputs = {
datadog_monitors = {
"monitor1" = {
name = "[kubernetes] Monitor Kubernetes Pods Restarting for app ${local.location_dir} on env ${local.env_vars.short_env}"
type = "query alert"
query = "change(sum(last_5m),last_5m):exclude_null(avg:kubernetes.containers.restarts{*} by {kube_cluster_name,pod_name}) > 5"
(...)
include_tags = true
// tags
tags = {
app = "${local.location_dir}"
type = "daemon"
env = "${local.env_vars.short_env}"
env_name = "${local.env_vars.environment}"
integration = "kubernetes"
// for instance here I would like to have a service TAG coming from the other file.
//something like service = "${local.service}". but it does not work of course.
service = "${local.service}"
}
thresholds = {
warning = 3
critical = 5
}
// Optional parameters
(...)
}
}
}
我试图在一份档案中添加这一内容,并在其他几个方面使用。
任何想法,如果有可能在<条码>中形成这种变数/地方/价值,则如何使用?
Edit是一些错误,即“未支持的属性;该物体没有被称作“服务”的属性。