Home > OS >  An argument or block definition is required here. set an argument, use the equals sign "="
An argument or block definition is required here. set an argument, use the equals sign "="

Time:07-08

I am trying to create a custom dataset for sink azure data factory using below terraform code. With a parameter i am getting error as : An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the argument value.. I don't understand what is error in here.

resource "azurerm_data_factory_custom_dataset" "datalakesink" {
  name            = "${var.dataset_name}_datalakesink"
  data_factory_id = azurerm_data_factory.adf.id
  type            = "Parquet"

  linked_service {
    name = "${var.applicationName}-${var.environment}-storagels"
    
  }
  type_properties_json = <<JSON 
  {
    "location": {
        "type": "AzureBlobFSLocation",
        "fileName": {
            "value": "@dataset().tablename",
            "type": "Expression"
                  },
        "folderPath": "Storage/Bronze/Datalake",
        "fileSystem": "casedetailfact"
                 }
    }
 JSON
    
 parameters = {
    tablename = ""
    }
 
 additional_properties = {}
 annotations = []
 

  lifecycle {
    ignore_changes = [data_factory_id]
  }
    depends_on = [azurerm_resource_group.myresourcegroup,azurerm_data_factory.adf,azurerm_data_factory_integration_runtime_self_hosted.ir,azurerm_data_factory_linked_custom_service.clihive-linked-service]

}

CodePudding user response:

You have a trailing whitespace on type_properties_json argument.

type_properties_json = <<JSON

I get the same error with whitespace locally as shown below::

harsha@MUCL104558:/tmp/tests$ terraform fmt -recursive
╷
│ Error: Invalid expression
│
│   on test.tf line 10, in resource "azurerm_data_factory_custom_dataset" "datalakesink":
│   10:   type_properties_json = <<JSON
│
│ Expected the start of an expression, but found an invalid expression token.
╵

╷
│ Error: Argument or block definition required
│
│   on test.tf line 22:
│   22:  JSON
│
│ An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the argument value.
╵

When whitespace is removed, I see it working::

harsha@MUCL104558:/tmp/tests$ terraform fmt -recursive
harsha@MUCL104558:/tmp/tests$ echo $?
0

In my opinion, this should have been handled by azurerm provider or terraform binary itself. I see suppressJsonOrderingDifference on type_properties_json argument here but don't know exactly what it does and doesn't.

  • Related