granadaCoder
granadaCoder

Reputation: 27904

azurerm_app_service create and get ip address

If I 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"
  }
}

This will create

https://MySuperCoolAppServer001.azurewebsites.net

using terraform output variables, I'm capturing id and name

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

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

Is there a way to get the IP address of MySuperCoolAppServer001 (https://MySuperCoolAppServer001.azurewebsites.net) via terraform as an output value?

I've tried the below 3, but no go.

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.

Upvotes: 1

Views: 348

Answers (1)

granadaCoder
granadaCoder

Reputation: 27904

Ok.

I found an answer. Better yet, I figured out how to "fish".

Yay to open source!

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

And now, "how to fish":

I found this by finding the source code:

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

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

I think the indicator is "Computed: true".

Hope that helps someone !

Upvotes: 2

Related Questions