gpt4 book ai didi

azure - Terraform 专门使用 "azurerm_synapse_linked_service"字段创建资源 "type_properties_json"时出现问题

转载 作者:行者123 更新时间:2023-12-03 05:22:21 29 4
gpt4 key购买 nike

我正在尝试创建 Synapse 工作区 Linked Service使用 Terraform 并经常遇到“type_properties_json”字段(必需)的问题。

当我尝试建立 SFTP 资源类型的链接服务时,我可以通过门户执行此操作,没有问题,但是尝试使用 Terraform 执行此操作会不断出现错误。我使用的是JSON代码格式referenced here ,但是“type_properties_json”字段不断出错,因为我相信它需要一个“String”,而我提供了一个 Map[string] 类型。

我在 terraform apply 期间不断收到的错误是 json: Cannot unmarshal string into Go value of type map[string]interface {}

我的具体代码如下所示:

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]

}

这里已经失去了希望,现在我正在寻求众包,看看是否有其他人遇到过这个问题!!

最佳答案

这是因为您传递的密码参数。根据这个Microsoft documentation ,应按如下方式传递:

        "password": {
"type": "SecureString",
"value": "<value>"
}

而不是

"password": <value>

我在我的环境中使用您的代码进行了相同的测试,我遇到了完全相同的问题:

Enter image description here

因此,我使用了以下代码,应用了上面提到的解决方案:

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
]
}

输出:

Enter image description here

Enter image description here

关于azure - Terraform 专门使用 "azurerm_synapse_linked_service"字段创建资源 "type_properties_json"时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71178279/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com