我是Terragrunt的新手,我遇到了一些情况,它是如何执行缓存的。
这就是我的文件结构。
├── monitor
│ └── files
│ └── graph
│ └── server
│ └── default
│ └── foo.json
└── terraform
├── env
│ └── stage
│ └── cluster
│ ├── provider.tf
│ └── terragrunt.hcl
├── moduleConfig
│ └── cluster
│ ├── backend.tf
│ ├── random.tf
│ ├── locals.tf
│ ├── outputs.tf
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── terragrunt.hcl但是当我运行一个terragrunt plan并查看.terragrunt-cache文件夹时,我看到的就是这个。
.terragrunt-cache/
└── KdPWtxpAXZdCe4otk2N9TY1tuQU
└── cwMVo-pYTWr47TeiHN8aORnD8g4
├── env
│ └── stage
│ └── cluster
│ ├── provider.tf
│ └── terragrunt.hcl
├── moduleConfig
│ └── cluster
│ ├── backend.tf
│ ├── random.tf
│ ├── locals.tf
│ ├── outputs.tf
│ ├── main.tf
│ ├── outputs.tf
│ ├── provider.tf
│ ├── terragrunt.hcl
│ └── variables.tf
└── terragrunt.hcl这会产生一个不想要的计划输出,因为我需要monitor目录中的资源。
尽管如此,我正在cluster目录中运行我的cluster。
├── env
│ └── stage
│ └── cluster这也许能解释这个问题。
有没有一种方法可以让Terragrunt也包含monitor目录,以便缓存包含包含我需要的所有文件的完整树?
谢谢。
#######################################################
更新为包含path和source块
include {
path = find_in_parent_folders()
}terraform {
source = "${path_relative_from_include()}//moduleConfig/cluster"
}#######################################################
发布于 2022-07-22 17:21:47
如果您希望monitor目录也被拉进来,您可能希望将terragrunt.hcl文件从terraform目录的根目录中取出,并将其放置在与monitor和terraform目录相同的路径上。
然后改变
terraform {
source = "${path_relative_from_include()}//moduleConfig/cluster"
}阅读
terraform {
source = "${path_relative_from_include()}//terraform/moduleConfig/cluster"
}这将使整个结构进入.terragrunt-cache目录。
如果你好奇地想知道它是如何工作的,这可能是一个很好的阅读。
https://terragrunt.gruntwork.io/docs/reference/built-in-functions/#path_relative_from_include
https://stackoverflow.com/questions/73080100
复制相似问题