terraform远程状态找不到属性

时间:2019-03-20 15:49:01

标签: terraform terraform-provider-azure

遇到的问题是data.terraform远程状态找不到属性,但是该属性存在于输出下。

数据代码:

data "terraform_remote_state" "network" {
  backend = "azurerm"

  config = {
    storage_account_name = ""
    container_name       = ""
    key                  = ""
    resource_group_name  = ""
    access_key           = ""
  }
}

尝试获取vnet,也尝试使用.outputs.vnet!

  vnet = "${data.terraform_remote_state.network.vnet}" // Also tested outputs.vnet and vnet_id, outputs.vnet_id

从我的远程状态文件中:

"outputs": {
                "resource_group": {
                    "sensitive": false,
                    "type": "string",
                    "value": "xxx"
                },
                "vnet": {
                    "sensitive": false,
                    "type": "string",
                    "value": "xxx"
                },
                "vnet_id": {
                    "sensitive": false,
                    "type": "string",
                    "value": "xxx"
                }
            },

错误:

  
      
  • module.jenkins_service.var.vnet:资源'data.terraform_remote_state.network'没有属性'vnet'   用于变量'data.terraform_remote_state.network.vnet'
  •   

1 个答案:

答案 0 :(得分:0)

您需要依赖terraform_remote_state和通用输出将数据传递到下游terraform运行的terraform azurerm的早期版本。首选方法是将数据作为第一类类型。例如,azurerm_virtual_networkdata sources