terragrunt-atlantis-config
terragrunt-atlantis-config copied to clipboard
Question: Finding file dependencies used in resource
Hey David, question for you. We have a module/resource with the following definition.
resource "vault_policy" "policies" {
for_each = toset(var.policies)
name = each.key
policy = templatefile("files/${each.key}.hcl.tmpl", { environment = var.environment })
}
How do I get these template files to show up as a dependency on the project?
I tried adding
locals {
extra_atlantis_dependencies = formatlist("files/%s.hcl.tmpl", var.policies)
}
to the terragrunt file, but it doesnt seem to like that.
Hi @ryan-dyer-sp - You would kind of add something like this to your child terragrunt.
locals {
(...)
# CICD for Atlantis
extra_atlantis_dependencies = [
"files/*.hcl.tmp
]
}
This tool (terragrunt-atlantis-config
) only needs to know what files need to be added to the workspace of your atlantis.yaml
config file.
@kitos9112 Thanks but I dont want a wildcard for changes to any policy to impact a project that doesnt have that specific file as a dependency.
In that case, you could create an aux. variable at local level beforehand and reuse it later within the extra_atlantis_dependencies
Is there any way you can create a local
which contains your policies instead of using var.policies
?
locals {
(...)
local.policies = <MyPolicies>
my_files = formatlist("files/%s.hcl.tmpl", local.policies)
# CICD for Atlantis
extra_atlantis_dependencies = local.my_files