# Getting attributes from Decode Json file

**URL:** <https://discuss.hashicorp.com/t/getting-attributes-from-decode-json-file/26020>\
**Category:** HCP Terraform\
**Tags:** testing, consul-template, hcp-terraform, azure\
**Created:** [June 26, 2021, 10:17am UTC](https://discuss.hashicorp.com/t/getting-attributes-from-decode-json-file/26020 "2021-06-26T10:17:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ighobulu](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ighobulu/32/17919_2.png) [@ighobulu](https://discuss.hashicorp.com/u/ighobulu)\
**Post date:** [June 26, 2021, 10:17am UTC](https://discuss.hashicorp.com/t/getting-attributes-from-decode-json-file/26020/1 "2021-06-26T10:17:12Z")

</div>

I have this Terraform code that decodes a JSON and CSV file.

```auto
provider "azurerm" {
    features{}
}

locals {
      resource_groupname = csvdecode(file("./ResourceTypes.csv"))
      json_data = jsondecode(file("${path.module}/Monitor.json"))
    }

    resource "azurerm_resource_group" "Main" {
      count = length(local.resource_groupname)
      name = local.resource_groupname[count.index].resourcetype
      location = "North europe"
    } 
     resource "azurerm_resource_group" "name" {
       # (other settings)
       name = local.json_data.name
       location = "North europe"
     }

      output "local_json_data" {
        value = local.json_data
      } 

```

when I run the terraform code I have the output as below

```auto
  # azurerm_resource_group.Main[212] will be created
  + resource "azurerm_resource_group" "Main" {
      + id = (known after apply)
      + location = "northeurope"
      + name = "Wandisco.Fusion"
    }

  # azurerm_resource_group.name will be created
  + resource "azurerm_resource_group" "name" {
      + id = (known after apply)
      + location = "northeurope"
      + name = "Azure-APIManagement-FailedRequests"
    }

Plan: 214 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + local_json_data = {
      + classification = "anomaly"
      + id = 16020941
      + message = <<-EOT
            Azure - API Management - Failed Requests
            {{name.name}} exceeds the previously estimated average.

            Please refer to the following reaction process:
            https://apptemetry/knowledgebase/Article.aspx?id=54321

            Alerts generate an AIM ticket, viewable here (search via CI or Alert Name):
            https://apptemetry/AIM/alertsearch.aspx
        EOT
      + name = "Azure-APIManagement-FailedRequests"
      + options = {
          + escalation_message = ""
          + include_tags = true
          + locked = false
          + new_host_delay = 300
          + no_data_timeframe = null
          + notify_audit = false
          + notify_no_data = false
          + renotify_interval = 0
          + require_full_window = true
          + silenced = {}
          + threshold_windows = {
              + recovery_window = "last_15m"
              + trigger_window = "last_15m"
            }
          + thresholds = {
              + critical = 1
              + critical_recovery = 0
            }
          + timeout_h = 1
        }
      + priority = null
      + query = "avg(last_4h):anomalies(avg:azure.apimanagement_service.failed_requests{*} by {name}, 'agile', 2, direction='above', alert_window='last_15m', interval=60, count_default_zero='true', seasonality='hourly') >= 1"
      + tags = [
          + "Sev:54",
        ]
      + type = "query alert"
    }

```

Is there a way I can hold the attributes from the JSON and CSV file, and save it to a variable as a string in terraform? and then make a new terraform script from the variables?

My end goal is to try and create a terraform script from a JSON file.
