1

如果我 azurerm_app_service

resource "azurerm_app_service" "testap" {
  name                = "MySuperCoolAppServer001"
  location            = "eastus"
  resource_group_name = "notshown"
  app_service_plan_id = "notshown"

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  app_settings {
    "SomeKey" = "SomeValue"
  }

  connection_string {
    name  = "Database"
    type  = "SQLServer"
    value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
  }
}

这将创建

https://MySuperCoolAppServer001.azurewebsites.net

使用 terraform 输出变量,我正在捕获 id 和 name

output "output_tf_testap_id" {
  value = "${azurerm_app_service.testap.id}"
}

output "output_tf_testap_name" {
  value = "${azurerm_app_service.testap.name}"
}

有没有办法通过 terraform 获取MySuperCoolAppServer001 ( https://MySuperCoolAppServer001.azurewebsites.net ) 的IP 地址作为输出值?

我已经尝试了以下3个,但不行。

does not have attribute 'ipaddress' for variable 'azurerm_app_service. 

does not have attribute 'ip_address' for variable 'azurerm_app_service.  

does not have attribute 'ip' for variable 'azurerm_app_service.
4

1 回答 1

2

好的。

我找到了答案。更好的是,我想出了如何“钓鱼”。

是的,开源!

output "output_tf_testap_outbound_ip_addresses" {
  value = "${azurerm_app_service.testap.outbound_ip_addresses}"
}

现在,“如何钓鱼”:

我通过查找源代码发现了这一点:

https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_app_service.go

        "outbound_ip_addresses": {
            Type:     schema.TypeString,
            Computed: true,
        },

我认为指标是“ Computed: true ”。

希望对某人有所帮助!

于 2018-07-13T12:58:44.370 回答