Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request : get azurerm_app_service custom domains ip address for azurerm_dns_a_record #14642

Open
dpa456 opened this issue Dec 16, 2021 · 6 comments

Comments

@dpa456
Copy link

dpa456 commented Dec 16, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Hello, I'm trying to reflect records in the azure_dns_a_record, and I need the inbound ip address of the azure app service.

Can you add or import the code for that part?

In ms, you can get it as inbound ip.
(https://docs.microsoft.com/en-us/azure/app-service/overview-inbound-outbound-ips)

New or Affected Resource(s)

  • azurerm_app_service

Potential Terraform Configuration

resource "azurerm_dns_a_record" "dns_a" {
  ...
  target_resource_id  = azurerm_app_service.target_app_service.custom_domain_ip
  or
  target_resource_id  = azurerm_app_service.target_app_service.inbound_ip_address
}

image

References

https://docs.microsoft.com/en-us/azure/dns/dns-web-sites-custom-domain
https://docs.microsoft.com/en-us/azure/app-service/overview-inbound-outbound-ips

When I looked it up, it looked like the issue. It's okay if you connect or merge it with that content.

#14385

@mateusz-opoka
Copy link

Hi! I've just found a workaround.

You can use hashicorp/dns provider to get this IP address by default hostname.

For example:

resource "azurerm_linux_web_app" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_service_plan.example.location
  service_plan_id     = azurerm_service_plan.example.id

  site_config {}
}

data "dns_a_record_set" "app_ip_address" {
  host = azurerm_linux_web_app.example.default_hostname
}

resource "azurerm_dns_a_record" "dns_a" {
  # ...
  target_resource_id  = data.dns_a_record_set.app_ip_address.addrs[0]
}

@dpa456
Copy link
Author

dpa456 commented Apr 1, 2022

Hi! I've just found a workaround.

You can use hashicorp/dns provider to get this IP address by default hostname.

For example:

resource "azurerm_linux_web_app" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_service_plan.example.location
  service_plan_id     = azurerm_service_plan.example.id

  site_config {}
}

data "dns_a_record_set" "app_ip_address" {
  host = azurerm_linux_web_app.example.default_hostname
}

resource "azurerm_dns_a_record" "dns_a" {
  # ...
  target_resource_id  = data.dns_a_record_set.app_ip_address.addrs[0]
}

Thank you for your answer.
Oh, that's a good suggestion.
I will test it soon and share the results.

@PurkkaKoodari
Copy link

+1. We are in the process of transferring an existing service, hosted at an apex domain (like contoso.com) to Azure, where we can't use a CNAME and thus need the IP address. We'd prefer not to resort to the DNS workaround.

It seems to me that this was already discussed in #5333, which was closed incorrectly. Unless using IP-based SSL, which comes with a significant additional cost, virtual_ip cannot be used for this purpose.

@dpa456
Copy link
Author

dpa456 commented Apr 30, 2022

@mateusz-opoka
Hello, I'm sorry for the delay in sharing.

I tested it, and I can get it from a single test well.
However, sometimes for a record, if you get it as 'each.key', you can't get it due to deployment timing.

And from my service point of view, I couldn't support azurem_linux_web_app due to version.
I'm still using the last argument of azurerm_app_service outbound_ip_address, and I hope to get inbound_ip_address from app_service.

If azurerm_linux_web_app using cannot process
my suggestion direction is as follows.

resource "azurerm_dns_a_record" "xtrm_dns_a" {
...
records = [element(split(",", "${azurerm_app_service.your_service_name.outbound_ip_addresses"), length(split(",", "$(azurerm_app_service.your_service_name.outbound_ip_addresses}")) -1)]
...
}

@dpa456
Copy link
Author

dpa456 commented Apr 30, 2022

+1. We are in the process of transferring an existing service, hosted at an apex domain (like contoso.com) to Azure, where we can't use a CNAME and thus need the IP address. We'd prefer not to resort to the DNS workaround.

It seems to me that this was already discussed in #5333, which was closed incorrectly. Unless using IP-based SSL, which comes with a significant additional cost, virtual_ip cannot be used for this purpose.

right, that part is # 14385 specified here.
Please refer to the link above

@xiaxyi
Copy link
Contributor

xiaxyi commented Jan 15, 2024

Hi All, terraform currently is not able to support this property until it got exposed by azure rest api. The issue is tracked via:Azure/azure-rest-api-specs#27377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants