Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Detecting Modified .hcl Files in Pre-Workflow Hook #349

Open
nattvasan opened this issue Aug 21, 2024 · 0 comments
Open

Issue with Detecting Modified .hcl Files in Pre-Workflow Hook #349

nattvasan opened this issue Aug 21, 2024 · 0 comments

Comments

@nattvasan
Copy link

nattvasan commented Aug 21, 2024

Description:

I'm encountering an issue when trying to detect modified .hcl files using a pre-workflow hook in Atlantis, particularly when leveraging the terragrunt-atlantis-config tool.

Problem:

I have a scenario where I need to list only the .hcl files that were modified in the most recent commit to ensure that Atlantis plans and applies the correct infrastructure changes. However, when I use the git show --name-only --pretty="" $HEAD_COMMIT | grep '\.hcl$' command in the pre-workflow hook, it lists all .hcl files in the commit, not just those that were modified.

terragrunt-atlantis-config generate --ignore-dependency-blocks --ignore-parent-terragrunt true --filter terragrunt/ --workflow terragrunt --output atlantis.yaml

Eventhough, there is modification to *.hcl file, terragrunt plan is not executing as per repos.yaml

atlantis.yaml generated:

  • autoplan:
    enabled: true
    when_modified:

    • '*.hcl'
    • '.tf'
    • ../../../../provider_config.hcl
    • ../../../../../terraform/modules/argocd-module/.tf
    • ../../../../../terraform/sub-modules/argocd/.tf
      dir: regions/westeurope/demo/argocd
      workflow: terragrunt

    My directory structure:

    infra/terragrunt/regions/westeurope/demo/argocd/terragrunt.hcl

    terraform {
    source = "${get_repo_root()}/terraform//modules/argocd-module/"
    }

infra/terraform/modules/argocd-module/main.tf

module "argocd" {
source = "../../sub-modules/argocd"
}

Expected Behavior:

  • If I change any *.tf files, I want atlantis to plan only *.hcl files but not *.tf

Error:
msg=open /atlantis-data/repos/devops1/infra/353/default/terraform/sub-modules/argocd/terragrunt.hcl: no such file or directory

but actually, the *.hcl is not under sub-modules/argocd/

  • The hook should only list .hcl files that were modified in the latest commit.

Actual Behavior:

All .hcl files in the commit are listed, regardless of whether they were modified.

Environment:

Atlantis App version: v0.28.3
Atlantis Helm chart version: atlantis-5.3.0
terragrunt-atlantis-config version: 1.18.0
Terraform version: v1.5.7
Terragrunt version: v0.57.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant