'Terraform issue creating the resource "azurerm_synapse_linked_service" specifically with the "type_properties_json" field
I am trying to create a Synapse Workspace Linked Service using Terraform and am running into a constant snag with the "type_properties_json" field that is (required).
When I try to establish a Linked Service to an SFTP resource type, I can do so through the portal no problem, however trying to do so with Terraform is constantly providing me with errors. I am using the JSON code format referenced here, but the "type_properties_json" field keeps erroring out as I believe it is expecting a "String" and I am instead providing a Map[string] type.
The error I keep receiving during the terraform apply is json: cannot unmarshal string into Go value of type map[string]interface {}
My specific code looks like the following:
resource "azurerm_synapse_linked_service" "linked-service" {
synapse_workspace_id = azurerm_synapse_workspace.synapse.id
name = "name"
type = "Sftp"
type_properties_json = <<JSON
{
"host": "x.x.com",
"port": 22,
"skipHostKeyValidation": false,
"hostKeyFingerprint": "ssh-rsa 2048 xx:00:00:00:xx:00:x0:0x:0x:0x:0x:00:00:x0:x0:00",
"authenticationType": "Basic",
"userName": "whatever_name,
"password": "randompassw"
}
JSON
depends_on = [azurerm_synapse_firewall_rule.allow]
}
Running out of hope here and am now looking to crowd source to see if anyone else has ever ran into this problem!!
Solution 1:[1]
This is because of the password parameter you are passing. As per this Microsoft documentation, it should be passed as below:
"password": {
"type": "SecureString",
"value": "<value>"
}
Instead of
"password": <value>
I tested the same in my environment using your code where I faced the exact same issue:
So, I used the below code, applying the solution mentioned above:
resource "azurerm_synapse_linked_service" "example" {
name = "SftpLinkedService"
synapse_workspace_id = azurerm_synapse_workspace.example.id
type = "Sftp"
type_properties_json = <<TYPE
{
"host": "xxx.xx.x.x",
"port": 22,
"skipHostKeyValidation": false,
"hostKeyFingerprint": "<SSH-publicKey>",
"authenticationType": "Basic",
"userName": "adminuser",
"password": {
"type": "SecureString",
"value": "<Value>"
}
}
TYPE
depends_on = [
azurerm_synapse_firewall_rule.example,
azurerm_synapse_firewall_rule.example1
]
}
Output:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter Mortensen |



