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

Digger runs Terraform instead of Opentofu #1706

Closed
peteher opened this issue Sep 12, 2024 · 3 comments · Fixed by #1707
Closed

Digger runs Terraform instead of Opentofu #1706

peteher opened this issue Sep 12, 2024 · 3 comments · Fixed by #1707

Comments

@peteher
Copy link

peteher commented Sep 12, 2024

Problem

Digger continues to use Terraform instead of OpenTofu in specific scenario, even though opentofu: true is explicitly defined.

Setup

  • Using Digger vLatest
  • no-backend setup
  • GitHub actions doing "plan" for branch PR and "apply" upon merge to main
  • migrating from Terraform 1.5.7 to Opentofu 1.8.2 where setup worked just fine with Terraform

GHA is as:

      - name: digger apply
        uses: diggerhq/digger@vLatest
        with:
          no-backend: true
          configure-checkout: true
          setup-aws: true
          aws-role-to-assume: "xxx"
          setup-opentofu: true
          opentofu-version: v1.8.2
          upload-plan-destination: aws
          upload-plan-destination-s3-bucket: 'xxx'
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Documentation does not explicitly say but there is a need for the project to state opentofu: true for Digger to start using OpenTofu.

So digger.yaml:

projects:
  - name: default
    workflow: my_custom_workflow
    opentofu: true
workflows:
  my_custom_workflow:
    workflow_configuration:
      on_pull_request_pushed: [ digger plan ]
      on_pull_request_closed: [ digger unlock ]
      on_commit_to_default: [ digger apply ]
auto_merge: false
telemetry: false

After adding opentofu: true to the project:

  • manual run is fine - plan and apply works properly, both using OpenTofu
  • PR triggered plan is also fine, using OpenTofu

However: PR merge triggered apply keeps using Terraform - and this is the problem.

Excerpt from log:

WARNING: running in 'backendless' mode. No policies will be supported.
GitHub context parsed successfully
Digger digger_config read successfully
Following projects are impacted by pull request #17
- default
GitHub event processed successfully
GitHub event converted to commands successfully
Following commands are going to be executed:
project: default: commands: "digger apply", 
Running 'digger apply' for project 'default' (workflow: my_custom_workflow)
PR status, mergeable: false, merged: true
Pre-apply plan retrieval: stored plan exists in artefact, retrieving
Running command: terraform [init -upgrade=true -input=false -no-color]

See above, running command "terraform" instead of "opentofu".

Workaround

It's not the nicest ever, but in the workflow I can fine-grain the "apply" steps to replace my terraform executable with tofu - so even though Digger keeps using terraform, it really is using tofu:

workflows:
  my_custom_workflow:
    apply:
      steps:
        - run: TF=`which terraform`; rm $TF; ln -s `which tofu` $TF
@motatoes
Copy link
Contributor

motatoes commented Sep 13, 2024

@peteher
Thanks for the detailed report, it helped me find the issue pretty quickly. It should be fixed in the next release

@peteher
Copy link
Author

peteher commented Sep 13, 2024

@motatoes
Thanks for the quick follow-up and fix! 🎉 Going to test and confirm resolution.

@peteher
Copy link
Author

peteher commented Sep 13, 2024

@motatoes
v0.6.42 worked like a charm - thanks again!

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

Successfully merging a pull request may close this issue.

2 participants