Skip to content

Include_patterns not working when "terragrunt=true" #2383

@ZIJ

Description

@ZIJ

In the Terragrunt == true branch digger seems to ignore include_patterns:

if b.Terragrunt == true {
if checkBlockInChangedFiles(*b.RootDir, changedFiles) {
slog.Info("generating terragrunt projects for block",
"blockName", b.BlockName,
"rootDir", *b.RootDir)
workflow := "default"
if b.Workflow != "" {
workflow = b.Workflow
}
// load the parsing config and override the block values
tgParsingConfig := b.TerragruntParsingConfig
if tgParsingConfig == nil {
tgParsingConfig = &TerragruntParsingConfig{}
}
tgParsingConfig.CreateProjectName = true
tgParsingConfig.DefaultWorkflow = workflow
tgParsingConfig.WorkflowFile = b.WorkflowFile
tgParsingConfig.FilterPaths = []string{path.Join(terraformDir, *b.RootDir)}
tgParsingConfig.AwsRoleToAssume = b.AwsRoleToAssume
tgParsingConfig.AwsCognitoOidcConfig = b.AwsCognitoOidcConfig
_, err := hydrateDiggerConfigYamlWithTerragrunt(config, *tgParsingConfig, terraformDir, b.BlockName, nil)
if err != nil {
slog.Error("failed to hydrate config with terragrunt",
"error", err,
"blockName", b.BlockName)
return nil, err
}
} else {
slog.Debug("skipping block due to no changed files", "blockName", b.BlockName)
}

while in the else branch it generates a project config which includes them:

includePatterns = []string{b.Include}
excludePatterns = []string{b.Exclude}
workflow := "default"
if b.Workflow != "" {
workflow = b.Workflow
}
workspace := "default"
if b.Workspace != "" {
workspace = b.Workspace
}
slog.Info("generating terraform projects for block",
"blockName", b.BlockName,
"include", b.Include,
"exclude", b.Exclude)
for _, dir := range dirs {
if MatchIncludeExcludePatternsToFile(dir, includePatterns, excludePatterns) {
projectName := strings.ReplaceAll(dir, "/", "_")
slog.Debug("creating project for directory",
"blockName", b.BlockName,
"dir", dir,
"projectName", projectName)
project := ProjectYaml{
Name: projectName,
Dir: dir,
Workflow: workflow,
Workspace: workspace,
OpenTofu: b.OpenTofu,
AwsRoleToAssume: b.AwsRoleToAssume,
Generated: true,
AwsCognitoOidcConfig: b.AwsCognitoOidcConfig,
WorkflowFile: b.WorkflowFile,
IncludePatterns: b.IncludePatterns,
ExcludePatterns: b.ExcludePatterns,
}
config.Projects = append(config.Projects, &project)
}
}

tagging @sidpalas @salsiy for visibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions