title: Parsing terraform plan output to check for module vs resource block usage
body: <p>I wanted to add a check to an existing terraform build and deployment pipeline to check that the configuration being written by devs is properly formatted and in line with company syntax</p>
  <p><strong>Specifically I want to check to make sure they are not using plain resource blocks in thier config as opposed to module blocks</strong></p>
  <p>For example I want to I want to make sure they are using</p>
  <pre><code>Module “eks_dev_wus2_app_cluster”
  </code></pre>
  <p>And not</p>
  <pre><code>Resource “aws_kubernetes_cluster” “eks_dev_wus2_App_cluster”
  </code></pre>
  <h2>Current approach</h2>
  <p>As I understand it I would need to first convert to json to parse through it</p>
  <pre><code>terraform show -no-color -json output.tfplan &gt; output.json
  </code></pre>
  <p>Then I should use the jq tool to parse through the output per this article
  <a href="https://linuxconfig.org/how-to-parse-a-json-file-from-linux-command-line-using-jq" rel="nofollow noreferrer">https://linuxconfig.org/how-to-parse-a-json-file-from-linux-command-line-using-jq</a></p>
  <p>A little fuzzy on how I would go about specifically checking the blocks in the terraform config to confirm whether or not they are resource or module.</p>
  <p>Can anyone point me in the right direction?</p>
  <p>Is there a better way to get output values? Don’t need an entire solution, just looking to clarify some of the fogginess of approaching this problem</p>