Git Product home page Git Product logo

devsectop / tf-via-pr Goto Github PK

View Code? Open in Web Editor NEW
62.0 4.0 11.0 31.87 MB

GitHub Action to plan and apply OpenTofu/Terraform (TF) via pull request (PR) automation.

Home Page: https://github.com/marketplace/actions/opentofu-terraform-via-pull-request

License: Apache License 2.0

HCL 1.45% JavaScript 98.55%
automation aws terraform devops cicd-pipeline github-actions-ci infrastructure-as-a-code opentofu reusable-workflows

tf-via-pr's People

Contributors

dependabot[bot] avatar p4perf4ce avatar rdhar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tf-via-pr's Issues

Add support for `merge_group` event trigger

Describe the bug

Per docs, you can increase development velocity with a merge queue for pull requests in your repository.

To do so, you must use the merge_group event to trigger your GitHub Actions workflow when a pull request is added to a merge queue.

Expected behavior

  1. When a given workflow with on.pull_request and on.merge_group event triggers is merged, the PR gets added to the merge where status checks are carried out.
  2. TF-via-PR should demonstrate compatibility with the merge_group event trigger by posting relevant TF command outputs as comments on the source PR.
  3. The success/failure of provisioning TF should be captured by associated status checks.

Additional context

This is inspired by #238 which requests support for workflow_dispatch event trigger.

Request: Support Compatibility with OpenTofu + `tenv`

Is your feature request related to a problem

N/a.

Describe the solution you'd like

With the launch of OpenTofu fork, I'd like to support OpenTofu as a first-class IaC provisioning tool, just like Hashicorp's Terraform.

Describe alternatives you've considered

While we await (pre-)releases to become available, a serviceable workaround has been shared by @zimeg (from Slack) to download, install and initialize OpenTofu CLI in 3 GitHub Actions steps.

- name: Download the tofu source
  uses: actions/checkout@v4
  with:
    repository: opentofu/opentofu
    path: opentofu

- name: Install tofu tooling
  uses: actions/setup-go@v4
  with:
    go-version-file: opentofu/go.mod
    cache-dependency-path: opentofu/go.sum

- name: Prepare the tofu command
  working-directory: opentofu
  run: |
    go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/tofu .
    echo $(pwd)/bin >> $GITHUB_PATH

Additional context

Issue opentofu/opentofu#556 has been raised in order to deliver a more "drop-in replacement"-able equivalent to hashicorp/setup-terraform.

Confirm support for `push` event trigger

Describe the solution you'd like

Ensure that this GitHub Action has full compatibility with push event triggered workflows, just as done with pull_request.types[closed] trigger for merging PRs.

Additional context

Inspired in chain by #238 and #242.

Would it be possible to include Terragrunt support with an example?

Is your feature request related to a problem

I would love to try this tool with my current Terragrunt setup. However, I don't see how I could integrate it with your tool.

Describe the solution you'd like

Besides installing and setting up Terraform, I wish to setup Terragrunt and have commands such as apply-all, plan-all, init-all, delete-all and others to be encompassed by this workflow.

Describe alternatives you've considered

I am considering using the Terragrunt github actions workflow, but it does not support triggering actions via comments. https://github.com/gruntwork-io/terragrunt-action

Additional context

N/A

Use PR comments instead of labels to trigger workflow automation

TL;DR

Our current Terraform IaC implementation enables deployment of multiple environments via GitHub Actions, allowing directory-based environment isolation and management of multiple backends/workspaces from a single repository.

We'd like to extend this to allow for management of multiple environments spanning different regions and/or AWS accounts to support the tiered needs of various sized clients with greater flexibility.

Specific Problems

Workflow

  • Our existing method relies on pull request labels to trigger the appropriate workflow for the environment(s) being deployed. While straightforward, this is too simple to target provisioning of specific resources.
  • It's also limited in terms of allowing CLI-based inputs, including: var-file, backend-config, and auto-approve to name a few.
  • By default, IaC is only provisioned on merge of the PR. Not ideal for validating changes since some plans can pass review but fail to apply due to unforeseen constraints (e.g., lack of subnet availability).

Multi-Region/Account

  • Separated backend.tfvars is finicky for local Terraform usage as we have to specify chdir and backend-config each time since Terraform does not support variable interpolation in backend configuration.
  • Directory naming convention, or lack thereof, is not conducive to provisioning of resources across regions or accounts without a structured approach.
  • Provisioning is tied to a single account by long-lived credentials to authenticate AWS access via access and secret keys.

Proposed Solution

Instead of labels, use pull request comments to trigger workflows.

  • Allows for more granular control over the provisioning of IaC, similar to local CLI usage or Atlantis runner.
  • Addresses validation of IaC before merge by applying a plan during the pull request workflow.
  • Create deployment markers automatically when a terraform plan is applied.

Request: User-configurable trigger keyword

Is your feature request related to a problem

At the moment, the only way this workflow can be triggered initially is via a comment starting with -terraform.

Describe the solution you'd like

I'd like this triggering keyword to be user-configurable. E.g., /terraform, -tf, etc.

Describe alternatives you've considered

N/a.

Additional context

N/a.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.