---
title: "Discussion on \"A simple way to Structure your Terraform code\" | Hashnode"
description: "Discussion on \"A simple way to Structure your Terraform code\". This article helps users structure their terraform code in a way that is easily readable and reduces the blast radius."
url: "https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A simple way to Structure your Terraform code](https://kubesimplify.hashnode.dev/a-simple-way-to-structure-your-terraform-code?utm_source=hashnode&utm_medium=feed)

This article helps users structure their terraform code in a way that is easily readable and reduces the blast radius.

Apr 13, 2022 · 4 min read · kubesimplify.hashnode.dev  
Updated Jun 20, 2022  
Read the article

-   [#terraform](https://hashnode.com/tag/terraform)
-   [#aws](https://hashnode.com/tag/aws)
-   [#blogging](https://hashnode.com/tag/blogging)
-   [#devops](https://hashnode.com/tag/devops)
-   [#infrastructure](https://hashnode.com/tag/infrastructure)

## Written by

[Leon](https://hashnode.com/@afrocoder)

@afrocoder · Jeju island

  
[View profile](https://hashnode.com/@afrocoder)

In a pod trying to tcpdump life.

Extremely bored all the time, but I love tech.

## Responses 5

Markdown supported · ⌘↵ to post

[Olaf Gradin](https://hashnode.com/@2mOlaf)

[May 31, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6296794ce78667ee04ce79bf)

Great addition to this space, [Leon](https://hashnode.com/@afrocoder)! Come join the Learning Terraform Discord server where you can chat with Leon and many others about Terraform or more general IaC practices. Invite code is 5fAwCK5R5W (discord \[dot\] gg).

[Asrin Dayananda](https://hashnode.com/@azcodez)

[Apr 26, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6268124f7b6a339ac2d01e73)

That's super useful! Going to use these in my IaC. 🤗

[{komlaetou}](https://hashnode.com/@komlaetou)

[Apr 14, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257cf8b049d83cc3e3ad745)

Thanks for this article. Is there a way to avoid blast radius without using remote state file? Assuming you are developing locally.

[{komlaetou}](https://hashnode.com/@komlaetou)

[Apr 14, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257cf8b049d83cc3e3ad745#reply-6257d18f049d83cc3e3ad791)

Found this terraform doc addressing my question [terraform.io/language/settings/backends/local](https://www.terraform.io/language/settings/backends/local)

[Leon](https://hashnode.com/@afrocoder)

[Apr 16, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257cf8b049d83cc3e3ad745#reply-625b1c432f84e0d4fc33d794)

Hey [Christopher K.M Etou](https://hashnode.com/@komlaetou) sorry I wasn't getting any notifications directly, glad you found the answer!

[Olaf Gradin](https://hashnode.com/@2mOlaf)

[May 31, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257cf8b049d83cc3e3ad745#reply-62967868e78667ee04ce79a1)

You might find some value in a recent video on this exact question here: YT: watch?v=Qg8VZsbaXxA&t=1416s. I can't post links yet, so you'll just have to add that query string to the YouTube URL ;)

[/dev/null](https://hashnode.com/@devnullroot)

[Apr 14, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257bef1049d83cc3e3ad575)

No mention of environments, modules,zero code re-use and an amateur take on Terraform.

I wouldn't call it best practices

[/dev/null](https://hashnode.com/@devnullroot)

[Apr 14, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257bef1049d83cc3e3ad575#reply-6257f73a2f84e0d4fc3392d3)

Oh I know blast radius. It doesn't do anything to help. Consider having an infra or multiple generic projects that have elevated permissions and multiple projects with their own state. Each team has access only to their own state with the pipeline only able to fetch(but not change) remote state from the elevated projects [Christopher K.M Etou](https://hashnode.com/@komlaetou)

[{komlaetou}](https://hashnode.com/@komlaetou)

[Apr 15, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257bef1049d83cc3e3ad575#reply-6258d64d52fb7bd53380bd24)

[/dev/null](https://hashnode.com/@devnullroot) I believe knowledge is a distributed system and the more we all contribute, the we all learn. Leon's article is the first block on how to modularize your terraform code.

The usecase you are describing is a valid one. Is there anything you found somewhere that could help complement Leon's article?

[Leon](https://hashnode.com/@afrocoder)

[Apr 16, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6257bef1049d83cc3e3ad575#reply-625b1de72f84e0d4fc33d7b3)

Hey [/dev/null](https://hashnode.com/@devnullroot) thanks for your inputs and yes I'm a newbie in Terraform, my focus was more on splitting your code into smaller pieces, each folder has its own state file so unless you're doing a terraform apply in all folders using something such as a CI/CD platform your code would definitely be much safer in a single repo, could you elaborate on environments, if you're pointing towards workspaces those are being deprecated and will only be available for terraform cloud backend/state, if you're referring to prod/dev env then this folder structure also works. While modules may help, that wasn't the focus of my article.

[Bushra Nazish](https://hashnode.com/@Bushra)

[Apr 13, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6256cdb9e58c4ac41a6752e7)

An amazing read 🙌

[Leon](https://hashnode.com/@afrocoder)

[Apr 16, 2022](https://hashnode.com/posts/a-simple-way-to-structure-your-terraform-code/6256c223375a6fc2370ae09d/comment/6256cdb9e58c4ac41a6752e7#reply-625b1df82f84e0d4fc33d7b9)

Thanks!
