Read Terraform's plan the better way

Suraj Narwade
Suraj in Cloud
Published in
2 min readDec 19, 2022

Last year, I started exploring, and studying terraform for work. While studying, I mostly relied on Terraform plan command to check the output plan.

As terraform module I was writing got bigger, the plan got bigger too, and I needed to store the plan in a file and then read & analyse the file later.

For example, I want to read the plan for the following resource & store it in a file,

resource "null_resource" "hello_world"{
provisioner "local-exec" {
command = "echo \"hello world\""
}
}

Like any Linux user, I ran the following command,

terraform plan > planfile

and then

because look at this file,

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:
[1m # null_resource.hello_world will be created
 + resource "null_resource" "hello_world" {
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.------------------------------------------------------------------------Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

After a lot of googling, I came across this life-changing flag,

terraform plan -no-color > planfile

and my life became easy and simple as it was before:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# null_resource.hello_world will be created
+ resource "null_resource" "hello_world" {
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.------------------------------------------------------------------------Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

I hope this helps and makes your life a bit easy.

Happy Terraforming!!!

Thank you so much for reading 😃 Have a great day 🎉

👋 Connect with me👋

🔥 Support My work ❤️

--

--

Suraj Narwade
Suraj in Cloud

All things Cloud, Containers & Developer Experience