atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Atlantis and Terraform Cloud/Enterprise not working with TF 1.6+

Open Eddman opened this issue 1 year ago • 0 comments

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

In Terraform 1.6.0 there is https://github.com/hashicorp/terraform/pull/33492 included. In this PR they enabled saving the plan in Terraform Cloud/Enterprise and using the saved plan with terraform apply in the next step.

But Atlantis is not able to coop with that new feature.

Plan works and shows the command line output. Apply however is not able to use the generated plan if there is no change and fails with the following error:

running "/atlantis/data/bin/terraform1.7.3 apply -input=false -auto-approve \"/atlantis/data/repos/....tfplan\"" in "/atlantis/data/repos/...": exit status 1
╷
│ Error: Saved plan has no changes
│ 
│ The given plan file contains no changes, so it cannot be applied. For more
│ details, view this run in a browser at:
│ https://<TFE DNS>/app/<org>/<workspace>/runs/<run ID>
╵

The plan file now always contains the following entries only:

{"remote_plan_format":1,"run_id":"run-FN67j6AW3owZq415","hostname":"tfe.deutsche-boerse.de"}

And Atlantis tries to apply even if there is no change planed. I assume it is not able to check that there are no changes.

Reproduction Steps

  1. Use terraform binary 1.6+
  2. Configure Atantis to plan & apply a workspace.
  3. Open a PR with changes in that workspace that have no effect on the infrastructure, atlantis plan, and atlantis apply
  4. running "/atlantis/data/bin/terraform1.7.3 apply -input=false -auto-approve \"/atlantis/data/repos/....tfplan\"" in "/atlantis/data/repos/...": exit status 1
    ╷
    │ Error: Saved plan has no changes
    │ 
    │ The given plan file contains no changes, so it cannot be applied. For more
    │ details, view this run in a browser at:
    │ https://<TFE DNS>/app/<org>/<workspace>/runs/<run ID>
    ╵
    

Logs

N/A

Environment details

  • Atlantis version: 0.26.0, also tested with 0.27.1
  • Deployment method: docker
  • If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: yes
  • Atlantis flags: docker run --restart always ... runatlantis/atlantis:v0.26.0 server --config /atlantis/atlantis.config.yaml
  • I have used Terraform 1.7.3 only, but the change is there since 1.6.0. We used previously TF 1.5, skipped 1.6.

Atlantis server-side config file:

# config file
atlantis-url: 'https://...removed...'
log-level: debug

gh-hostname: '...removed...'
gh-app-id: '53'
gh-app-slug: '...removed...
gh-app-key: |
  ...removed...

gh-webhook-secret: '...removed...'
write-git-creds: true

allow-fork-prs: false
silence-fork-pr-errors: true
repo-allowlist: '...removed...'

vcs-status-name: 'atlantis-risk-shared-infra-dev'
hide-prev-plan-comments: true
allow-draft-prs: true
skip-clone-no-changes: true
# checkout-strategy: merge

enable-regexp-cmd: true

default-tf-version: v1.7.3

ssl-cert-file: /atlantis/certs/atlantis.crt
ssl-key-file: /atlantis/certs/atlantis.key
repo-config: /atlantis/atlantis.repos.yaml
data-dir: /atlantis/data/

tfe-hostname: '...removed...'
tfe-token: '...removed...'

Repo atlantis.yaml file:

version: 3
automerge: false
parallel_plan: true
parallel_apply: true
projects:
  - name: ...removed...
    dir: ...removed...
    workspace: ...removed...
    terraform_version: 1.7.3
    autoplan:
      when_modified:
        - "...removed..."

Additional Context

Eddman avatar Feb 21 '24 15:02 Eddman