Terragrunt: Template_dir Broken with 0.19.19

Created on 12 Aug 2019  路  7Comments  路  Source: gruntwork-io/terragrunt

Error: failed to render templates/.terragrunt-source-manifest: :1,2-3: Invalid character encoding; All input files must be UTF-8 encoded. Ensure that UTF-8 encoding is selected in your editor., and 1 other diagnostic(s)

The issue is that .terragrunt-source-manifest is not in UTF-8 format. So the template_dir fails.

It is working with Terragrunt 0.19.11 and Terraform 0.12.6

enhancement help wanted

All 7 comments

Just more details.
When template_dir is used, it walks through the whole directory, taking all files.
.terragrunt-source-manifest is obviously is not in UTF-8, because it's a binary file, and it's good it fails, otherwise results would interesting.

There doesn't seem to be a way to skip "hidden" files.

To me, template_dir should skip dotfiles, opened https://github.com/terraform-providers/terraform-provider-template/issues/68

I'm not sure if there is an easy fix from terragrunt side.

Thx @ekini!

I ran into this problem when porting my codebase to terragrunt but found the following workaround to approximate template_dir behaviour with local_file, fileset() and templatefile()

resource "local_file" "generated_file" {
  for_each = fileset("my_source_dir", "[^.]*")
  filename = "my_destination_dir/${each.value}"

  content = templatefile("my_source_dir/${each.value}", {
    "my_var" = "my_value"
  })  
}

Pattern syntax can be found here

Workaround to this is copy the .helmignore adding the .terragrunt-source-manifest in the .teragrunt-cache/RANDOM_HASH/YOUR_CHART after the fist failure.

A workaround is either to use an absolute path or pass the path of the terragrunt directory using get_parent_terragrunt_dir() and work off of that path

A workaround that I've been using successfully:


resource "local_file" "helm_ignore" {
  content  = templatefile("${path.module}/templates/helmignore.tpl", {})
  filename = "${local.chart_terragrunt_dir}/.helmignore"
}

locals {
 chart_terragrunt_dir  = "${abspath(path.root)}/chart"
}

And the content for ${path.module}/templates/helmignore.tpl:

# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
ci/
.terragrunt-source-manifest
.terragrunt-source-manifest/
Was this page helpful?
0 / 5 - 0 ratings