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

Support for Data Source: azurerm_public_ip #23430

Open
1 task done
volodymyrvikorsky opened this issue Oct 1, 2023 · 0 comments
Open
1 task done

Support for Data Source: azurerm_public_ip #23430

volodymyrvikorsky opened this issue Oct 1, 2023 · 0 comments

Comments

@volodymyrvikorsky
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

Hi. Please implement a depends_on option for Data Source: azurerm_public_ip. This option can help to use the output of the first Data Source as the input arguments for the next Data Sources

  • 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 and review the contribution guide to help.

Description

Hi. Please implement a depends_on option for Data Source: azurerm_public_ip (https://registry.terraform.io/providers/hashicorp/Azurerm/latest/docs/data-sources/public_ip). Why? I try to explain in a few words. You should enter the name of the public IP address and resource_group_name arguments to fetch an ip_address attribute. I've met a case when Terraform did not create this IP address. I don't have this resource and its name in the Terraform configuration files. So I applied Data Source: azurerm_resources using required_tags to fetch this name of the public IP resource from Azure Portal at the beginning and then to use this name as an argument in Data Source: azurerm_public_ip.
It looks like the following part of the code:

data "azurerm_resources" "public_ip_name" {
resource_group_name = "example-resources"
required_tags = {
environment = "production"
role = "webserver"
}
}
output "public_ip_name" {
value = data.azurerm_resources.public_ip_name.name
}

data "azurerm_public_ip" "public_ip_address" {
name = data.azurerm_resources.public_ip_name.name
resource_group_name = "example-resources"
}

output "public_ip_address" {
value = data.azurerm_public_ip.public_ip_address.ip_address
}
As a result, I've received an error that the name argument is not defined. It seems to me that the second Data Source started to look for public_ip_address before the first Data Source retrieved the name from Azure Portal. I guess using a depend_on option in the second Data could solve this issue. Would you implement this option for Data Source? Thank You.
P.S. Import this public IP resource into the Terraform file is not allowed

New or Affected Resource(s)/Data Source(s)

data.azurerm_public_ip

Potential Terraform Configuration

data "azurerm_public_ip" "public_ip_address" {
name = data.azurerm_resources.public_ip_name.name
resource_group_name = "example-resources"

depends_on = [data.azurerm_resources.public_ip_name]
}

output "public_ip_address" {
value = data.azurerm_public_ip.public_ip_address.ip_address
}

References

No response

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

2 participants