0

I have created Azure database for mysql using terraform and have enabled access to azure services in it using terraform, so is there a way to add client IP also in it through terraform only?

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67

1 Answers1

0

Use azurerm_mysql_firewall_rule or azurerm_mysql_flexible_server_firewall_rule if that is what you are using

resource "azurerm_resource_group" "example" {
  name     = "api-rg-pro"
  location = "West Europe"
}

resource "azurerm_mysql_server" "example" {
  # ...
}

resource "azurerm_mysql_firewall_rule" "example" {
  name                = "office"
  resource_group_name = azurerm_resource_group.example.name
  server_name         = azurerm_mysql_server.example.name
  start_ip_address    = "40.112.8.12"
  end_ip_address      = "40.112.8.12"
}
Alex AIT
  • 17,361
  • 3
  • 36
  • 73
  • it adds a specific ip, but i want to add the client ip – abhsihek Jan 19 '22 at 15:53
  • https://stackoverflow.com/questions/46763287/i-want-to-identify-the-public-ip-of-the-terraform-execution-environment-and-add – Alex AIT Jan 19 '22 at 15:54
  • not public ip, i want to add the client ip – abhsihek Jan 19 '22 at 15:57
  • i tried this by adding firewall resource twice, one for public ip and one for client ip, so it worked fine, which resolves my requirement, Thanks – abhsihek Jan 20 '22 at 11:01
  • @abhsihek Thank you for following up. If you feel your question was resolved, please consider marking the answer as "accepted". This helps keep the focus on older questions which still don't have answers. – Alex AIT Jan 20 '22 at 12:29