Skip to content

Atlantis server doesn't do anything after terraform init #5593

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

Open
thisjdzhang opened this issue May 22, 2025 · 3 comments
Open

Atlantis server doesn't do anything after terraform init #5593

thisjdzhang opened this issue May 22, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@thisjdzhang
Copy link

thisjdzhang commented May 22, 2025

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

I have a custom workflow

version: 3
projects:
  - name: monitoring
    dir: bootstrap/monitoring
    workspace: my-monitoring
    terraform_version: v1.10.0
    autoplan:
      when_modified: ["*.tf"]
      enabled: true
    apply_requirements: [approved]
    workflow: custom

workflows:
  custom:
    plan:
      steps:
        - run: terraform init
        - run: terraform plan
    apply:
      steps:
        - run: terraform init
        - run: terraform apply

Based on logs, the terraform server doesn't do anything after running the terraform init

The github checks just hang there.

Reproduction Steps

Logs

{"level":"info","ts":"2025-05-22T17:52:22.709Z","caller":"models/shell_command_runner.go:181","msg":"successfully ran 'sh -c' 'terraform init' in '/home/atlantis/.atlantis/repos/{redacted}/bootstrap/monitoring'","json":{"repo":"{redacted}","pull":"605","duration":3.925247448}}

Latest comment is ^^ and nothing gets printed after that.

Environment details

Additional Context

@thisjdzhang thisjdzhang added the bug Something isn't working label May 22, 2025
Copy link

dosubot bot commented May 22, 2025

Based on your description and logs, Atlantis successfully runs terraform init in your custom workflow, but then hangs and does not proceed to terraform plan. The GitHub checks remain pending at the "plan" stage.

Here are some key points and troubleshooting steps:

  • Custom Workflow Step Handling: In Atlantis, custom commands (like your run: terraform init) will only terminate if all output file descriptors are closed. If a command's output is not redirected, it can block the workflow and cause Atlantis to hang. This is especially relevant if you have any background processes or scripts in your workflow steps, but even standard commands can sometimes behave unexpectedly if they produce output that isn't handled properly. See the custom workflows documentation for details.

  • Exit Codes: If any step in your workflow returns a non-zero exit code, Atlantis will stop the workflow at that point. However, your logs indicate that terraform init completed successfully, so this is less likely the cause unless terraform plan is failing silently or not being invoked at all.

  • Atlantis Version Bug: There is a known bug in Atlantis v0.4.14 that causes Terraform execution to stall on large infrastructures. If you are using this version, it is recommended to upgrade to v0.4.15 or later to avoid this issue. See the CHANGELOG.

  • Custom Step Execution: Custom steps in Atlantis bypass the normal Terraform execution flow, which can affect environment variable propagation and other internal behaviors. This can sometimes lead to unexpected results if your workflow relies on Atlantis-specific environment handling or output parsing. More on this in this discussion.

Troubleshooting suggestions:

  1. Double-check your Atlantis version and upgrade if necessary.
  2. Try redirecting the output of your custom steps, for example:
    plan:
      steps:
        - run: terraform init > init.log 2>&1
        - run: terraform plan > plan.log 2>&1
    This ensures that all output is handled and the workflow can proceed.
  3. Increase logging verbosity in Atlantis to capture more details about what happens after terraform init.
  4. Test with a minimal workflow (e.g., just terraform plan) to isolate whether the issue is with terraform init or the transition to the next step.

If the problem persists after these steps, please provide more details about your Atlantis version and any additional logs or error messages you see.

To continue talking to Dosu, mention @dosu-bot.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@thisjdzhang
Copy link
Author

thisjdzhang commented May 22, 2025

Thanks for the suggestions. But I would like to know if it's true that simply running terraform init in a run step isn't working or I configured something incorrectly?

Copy link

dosubot bot commented May 22, 2025

Running terraform init in a run step within an Atlantis custom workflow is supported and should work, as long as the command completes and all output file descriptors are properly handled. However, the Atlantis documentation notes that if a custom command's output is not redirected or handled, it can cause the workflow to hang. This is not specific to terraform init—any command in a run step can block if its output is not managed correctly.

There is no general or documented bug that prevents terraform init from working in a run step. The most common cause for the behavior you describe (where the workflow hangs after terraform init) is improper output handling in the custom workflow step, not an inherent problem with terraform init itself. If output is not consumed or redirected, Atlantis may wait indefinitely for the process to finish, which matches the symptoms you are seeing.

To summarize: simply running terraform init in a run step does work, but you must ensure that output is handled so the process can terminate cleanly. If you experience hanging, it is likely due to output handling rather than a fundamental issue with terraform init in a run step. You can find more details in the custom workflows documentation.

To continue talking to Dosu, mention @dosu-bot.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant