runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.78k stars 1.05k forks source link

Pre workflow hook not being executed #1813

Closed pkaramol closed 2 years ago

pkaramol commented 3 years ago

Community Note


Overview of the Issue

I am starting my atlantis server with the following flags

export AWS_ACCESS_KEY_ID=XXX && export AWS_SECRET_ACCESS_KEY=XXX && atlantis server --atlantis-url=http://1.1.1.1 --port=4242 --gh-user=pkaramol --gh-token=XXX --gh-webhook-secret=XXX --gh-hostname=github.com --repo-allowlist='github.com/pkaramol/atlantis-poc' --log-level=debug --repo-config=repoconfig.json

where

{
  "repos": [
    {
      "id": "github.com/pkaramol/atlantis-poc",
      "workflow": "default",
      "pre_workflow_hooks": [
        {
          "run": "terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --create-workspace"
        }
      ]
    }
  ]
}

However, upon atlantis plan execution everything fails and it seems the plain terraform command is being executed

running "/usr/local/bin/terraform plan -input=false -refresh -no-color -out \"/home/ubuntu/.atlantis/repos/pkaramol/atlantis-poc/2/default/default.tfplan\"" in "/home/ubuntu/.atlantis/repos/pkaramol/atlantis-poc/2/default": exit status 1

Error: No configuration files

Plan requires configuration to be present. Planning without a configuration
would mark everything for destruction, which is normally not what is desired.
If you would like to destroy everything, run plan with the -destroy option.
Otherwise, create a Terraform configuration file (.tf file) and try again.

For repo id I have also tried using the value of /.*/

Using atlantis 0.17.3 on Ubuntu 20.04.3

atlantis debug-level logs.

btsuhako commented 3 years ago

@pkaramol - are you using terragrunt-atlantis-config@1.9.0? I saw some similar behavior with that version, and had to revert to our previously working 1.7.2

using atlantis 0.17.3 and terragrunt 0.32.3

pkaramol commented 3 years ago

@btsuhako yes my question was in the scope of trying to use terragrunt-atlantis-config;

here is how I managed to solve it (no atlantis.yaml needed)

repos:
- id: "/.*/" # (or <your_repo_id>)
  allowed_overrides: [workflow, apply_requirements]
  allow_custom_workflows: true
  workflow: terragrunt
  apply_requirements: [mergeable]
  pre_workflow_hooks:
    - run: terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --create-workspace
workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan -no-color -out=$PLANFILE
      - run: terragrunt show -no-color -json $PLANFILE > $SHOWFILE
    apply:
      steps:
      - run: terragrunt apply -no-color $PLANFILE
jamengual commented 2 years ago

is this still an issue with v0.19.8?