February 22, 2022 By Nishu Bharti 4 min read

Analyzing Terraform files that have many lines of code spread across multiple files is cumbersome, and it can be confusing to understand the dependencies between modules, resources and data-sources.

This is further aggravated when you are trying to assess the impact of any small change in the Terraform configuration file.  

In this blog post, I’ll show you how you can use Blast Radius to simplify the Terraform resources and data source visualization. 

About Terraform and Blast Radius

Terraform was developed by Hashicorp and works on the principles of Infrastructure as Code (IaC). IBM uses Terraform as the default IaC-based automation engine in its product. For more information, refer to the Terraform on IBM Cloud documentation.

Blast Radius is an open-source tool used for reasoning about Terraform dependency graphs with an interactive view. You can use Blast Radius to do the following:

  • Learn about Terraform or one of its providers through real-time examples.
  • Document your IaC.
  • Reason the relationships between the resources and evaluate the differences.

IBM has enhanced the capabilities in Blast Radius to view the IBM Cloud Terraform configuration files, Terraform plan files and the Terraform state files (with additional details like cost estimate, time estimate and policy compliance for each resource in the graphical view).

Prerequisites

  • Python3.7 or higher version
  • Terraform v0.12 or higher used to generate the following:
    • Terraform plan json file
    • Terraform state file (after running the Terraform apply command)
    • Terraform cost estimator for IBM Cloud (to generate the cost.json file)
    • OPA Policy evaluation tool for IBM Cloud (to generate the policy.json file)

Usage

Install latest release of the Blast Radius wheel from the IBM Cloud repository via this command:

pip3 install blastradius-0.1.25.1-py3-none-any.whl

Verify the Blast Radius installation: 

blast-radius help

The output should look something like this: 

Figure 1: Blast Radius installation help.

Running Blast Radius 

Follow these steps to run Blast Radius in your local system with a sample Terraform configuration:

  1. Download your Terraform templates to your local machine in a working directory:
  2. Generate the tfplan.json:
    • Run the terraform init command in the Terraform working directory.
    • Generate the terraform plan –out=tfplan.binary command.
    • Show terraform show -json tfplan.binary > tfplan.json to convert the Terraform plan binary data into JSON format. Note: ‘tfplan.json` is the mandatory file to provide cost and policy information in the graph. 
  3. Generate the Terraform state files (this is not mandatory step):
    • Run the terraform apply command in the Terraform working directory.
  4. Copy the static/images folder from Blast Radius directory to the Terraform working directory: 
    • The static folder contains Blast Radius images for the graphic display.
  5. Run the blast-radius --serve . command to view the graph.
  6. Open your browser with <URL> to view the graph as shown in the following screen capture:

    Figure 2: Complete view of Terraform configuration.

Working with Blast Radius graphs 

The rows represent nodes, and they have on-click functionalities. The first row depicts the dependent path of the node, as shown in Figure 3:

Figure 3: On-click functionality.

When you on-click the plan row, you will get the plan data of the particular resource in the side panel, as shown in Figure 4:

Figure 4: On-click the plan row.

Similarly, you can view the cost and policy information of the resources in the respective view, but for that, you need to have cost data and policy data in the form of cost.json and policy.json in the directory. You can also filter the graph based on their nodes:

Figure 5: Filter view by the node name in the search bar.

You can also pure the graph to minimize its view and visualize it in a wider and clearer view. To do so, you need to select the node and click on the purge symbol. The view will be something like what is shown in Figure 6:

Figure 6: Purge view.

There are other features like zoom in and zoom out, and you can also download an .svg file of your graph.

Get started with Blast Radius

In this post, you learned how you can use Blast Radius to simplify Terraform resources and data source visualization. 

To explore more about Blast Radius and to contribute, use the Blast Radius repository

Was this article helpful?
YesNo

More from Cloud

Microcontrollers vs. microprocessors: What’s the difference?

6 min read - Microcontroller units (MCUs) and microprocessor units (MPUs) are two kinds of integrated circuits that, while similar in certain ways, are very different in many others. Replacing antiquated multi-component central processing units (CPUs) with separate logic units, these single-chip processors are both extremely valuable in the continued development of computing technology. However, microcontrollers and microprocessors differ significantly in component structure, chip architecture, performance capabilities and application. The key difference between these two units is that microcontrollers combine all the necessary elements…

Seven top central processing unit (CPU) use cases

7 min read - The central processing unit (CPU) is the computer’s brain, assigning and processing tasks and managing essential operational functions. Computers have been so seamlessly integrated with modern life that sometimes we’re not even aware of how many CPUs are in use around the world. It’s a staggering amount—so many CPUs that a conclusive figure can only be approximated. How many CPUs are now in use? It’s been estimated that there may be as many as 200 billion CPU cores (or more)…

Prioritizing operational resiliency to reduce downtime in payments

2 min read - The average lost business cost following a data breach was USD 1.3 million in 2023, according to IBM’s Cost of a Data Breach report. With the rapid emergence of real-time payments, any downtime in payments connectivity can be a significant threat. This downtime can harm a business’s reputation, as well as the global financial ecosystem. For this reason, it’s paramount that financial enterprises support their resiliency needs by adopting a robust infrastructure that is integrated across multiple environments, including the…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters