# Terraform template\_file Empty Json validation

**URL:** <https://discuss.hashicorp.com/t/terraform-template-file-empty-json-validation/30883>\
**Category:** Terraform\
**Tags:** azure\
**Created:** [October 19, 2021, 1:54pm UTC](https://discuss.hashicorp.com/t/terraform-template-file-empty-json-validation/30883 "2021-10-19T13:54:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayendranarumugam](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jayendranarumugam/32/23124_2.png) [@jayendranarumugam](https://discuss.hashicorp.com/u/jayendranarumugam)\
**Post date:** [October 19, 2021, 1:54pm UTC](https://discuss.hashicorp.com/t/terraform-template-file-empty-json-validation/30883/1 "2021-10-19T13:54:13Z")

</div>

My Terrform code would like below. Here my parameters file some time have values and most of the time would be an empty JSON `{}`

```
resource "azurerm_policy_assignment" "example" {
  name = "example-policy-assignment"
  scope = azurerm_resource_group.example.id
  policy_definition_id = azurerm_policy_definition.example.id
  description = "Policy Assignment created via an Acceptance Test"
  display_name = "My Example Policy Assignment"

  parameters = "${data.template_file.policy_parameters_file.rendered}"

```

So I need to do some validation to check if my parameter file is empty json then I need to assign an empty string.

I tried like below but its not working

```auto
"${data.template_file.policy_parameters_file.rendered}" == {} ? "" : "${data.template_file.policy_parameters_file.rendered}"

```

This validation is needed as the state files were already having value for parameter as “”. Now if i ran the terraform plan it showing as

```auto
parameters = jsonencode({}) # forces replacement 

```

which makes force replacement.

If i hardcode the parameter to “” all goes well. So to handle this i need to find a way to handle the validation of empty json in the parameter file. If the json is empty I need to pass as “”
