Closed skumble closed 2 months ago
Hello,
this is by design (if terraform.source
is defined), in .terragrunt-cache
is downloaded terraform sources, generated files if required, and invoked Terraform
Hello, thanks for the response.
Any alternative method to achieve this "resource "local_file"" in terragrunt ?
Hey @skumble , it depends on what you're trying to do.
One simple way to do this is to use the get_terragrunt_dir function to construct a file path, then pass that into your modules as a variable.
e.g.
# terragrunt.hcl
inputs = {
filename = "${get_terragrunt_dir()}/foo.bar"
}
# main.tf
variable "filename" {}
resource "local_file" "this" {
filename = var.filename
content = "foo! test test test"
}
Hi, can be used a couple of ideas:
terraform.source
is not defined, then the working directory is the current dir so files will be created in the same location where terragrunt.hcl
is locatedhttps://github.com/gruntwork-io/terragrunt/issues/3324#issuecomment-2273294503 This helped. Thanks a lot @yhakbar yhakbar
Describe the bug
When i run the
terragrunt
apply for the below terraform code it does not create the file "foo.bar" in the path "../modules/cassandra/instance_creation/files/" instead i could find it in inside the ".terragrunt-cache"Steps To Reproduce
Steps to reproduce the behavior, code snippets and examples which can be used to reproduce the issue.
Expected behavior
The "foo.bar" file should be created when the terragrunt apply command is run
Nice to haves
$ cat .//spaces-live-infra-terragrunt/live/sandbox/us-gov-west-1/core-app-infra/managed-services/cassandra/.terragrunt-cache/LitHMSlLlB0uHHqYge-DouolS10/Fsd8cV2oG0EvjtpJIXo91yn-Pa0/modules/eks-services/modules/cassandra/instance_creation/files/foo.bar foo! test test test
Versions
Terragrunt version: $ terragrunt --version terragrunt version 0.63.3
OpenTofu/Terraform version: $ terraform --version Terraform v1.9.2 on darwin_arm64
Environment details (Ubuntu 20.04, Windows 10, etc.): mac 14.5 (23F79) Sonoma
Additional context
Add any other context about the problem here.