runatlantis / atlantis

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

Atlantis workflow is stuck on 'init' step without error #3797

Open EvgeniNeosec opened 1 year ago

EvgeniNeosec commented 1 year ago

Community Note


Description

I have a custom workflow that should run with 'autoplan' when a PR is open I configured the workflow with pre_workflow_hooks

repos:
- id: /.*/
  pre_workflow_hooks:
    - run: |
        echo "generating atlantis.yaml"
        cat > atlantis.yaml <<EOL
        version: 3
        delete_source_branch_on_merge: false
        parallel_plan: true
        projects:
          - name: atlantis-plan-stg
            workspace: stg
            workflow: workflow-1
            dir: terraform
            terraform_version: v1.5.5
            delete_source_branch_on_merge: false
            autoplan:
              enabled: true
              when_modified: ["*.yml","*.tf","*.md"]
          - name: atlantis-plan-stg-eu
            workspace: stg-eu
            workflow: workflow-1
            dir: terraform
            terraform_version: v1.5.5
            delete_source_branch_on_merge: false
            autoplan:
              enabled: true
              when_modified: ["*.yml","*.tf","*.md"]
        workflows:
          workflow-1:
            plan:
              steps:
                - run: env 
                - run: terraform init -reconfigure -lock=false -input=true 
                - run: terraform plan -var-file="stg.tfvars" -input=false -out $PLANFILE 

But when this flow is running, it's simply stuck without any error, on the init step: Screenshot 2023-09-27 at 11 15 28 AM

This is how the PR box looks: Screenshot 2023-09-27 at 5 50 14 PM

pod logs on job run:

{"level":"info","ts":"2023-09-27T14:33:01.936Z","caller":"runtime/pre_workflow_hook_runner.go:80","msg":"successfully ran "bash -cv echo \"generating atlantis.yaml\"\ │ │ ncat > atlantis.yaml <<EOL\nversion: 3\ndelete_source_branch_on_merge: false\nparallel_plan: true\nprojects:\n - name: atlantis-plan-stg\n workspace: stg\n wo ││ rkflow: workflow-1\n dir: terraform\n terraform_version: v1.5.5\n delete_source_branch_on_merge: false\n autoplan:\nworkflows:\n workflow-1:\n plan:\ ││ \n steps:\n - run: env \n - run: terraform init -reconfigure -lock=false -input=true \n - run: terraform plan -var-file=\"stg.tfvars\" -inp │ │ ut=false -out $PLANFILE \n - run: echo $PLANFILE\nEOL\necho \"atlantis.yaml is genrated!\"\n" in "/atlantis-data/repos/neosec-com/lambda-websocket-handler/ ││ 58/default"","json":{"repo":"neosec-com/lambda-websocket-handler","pull":"58"}}

Expected behavior: When a PR is open, I need both projects (atlantis-plan-stg, atlantis-plan-stg-eu)to run one after another And be successfully completed on the PR page

Additional info: Atlantis is running on EKS - Helm installation Chart version: 4.15.2 - https://github.com/runatlantis/helm-charts Atlantis version: latest Terraform version: 1.5.5

X-Guardian commented 11 months ago

You have -input=true on your init step, so it is likely that Terraform is waiting for user input on that step