Improve Terraform Ultimate Plan Output in GitHub Actions – DZone – Uplaza

Terraform is an Infrastructure as Code (IaC) instrument that enables the DevOps engineer to automate the availability and administration of infrastructure sources. It makes use of configuration recordsdata written in HashiCorp Config Language (HCL) to outline the specified state of the infrastructure and has varied instructions to configure and apply the infra sources. 

GitHub Actions is a steady integration and supply platform (CI/CD) that enables builders to automate construct, check, and deployment pipelines. In the course of the deployment configuration, we have to outline a step: a step is a person motion that GitHub Actions performs. 

Present State

Whereas deploying an infrastructure useful resource by Terraform usually, the Terraform plan output exhibits all of the execution logs and shows the ultimate plan output ultimately. If many infrastructure adjustments are happening on the similar time, all adjustments will get dumped right into a single plan output, and the reviewer must scroll right down to see the ultimate output. It might result in distraction and the potential for lacking the ultimate plan output clearly, which ends up in destroying the sources accidentally after execution.  

Proposed Answer

On this article, I’ve given an easier answer to learn how to overcome the above downside in an easier means. This can separate the Terraform output step into 3 steps.

Prerequisite

For this mock pipeline execution, I’ve used Google Cloud for the useful resource deployment. Earlier than the code execution, arrange the Google credentials as required (highlighted within the under code snippet).  

Step 1

Introduce a brand new step in GitHub actions to gather all Terraform stdout log output.

Step 2

This output must be saved right into a GitHub output variable.

Step 3

Use the output variable within the subsequent steps, filter the plan output log alone to show on this step execution log, and supply the textual content contents and background coloration to realize consideration in the course of the pull request opinions. 

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version