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

azurerm_mssql_outbound_firewall_rule - New resource #14795

Merged
merged 3 commits into from Feb 16, 2022

Conversation

aristosvo
Copy link
Collaborator

@aristosvo aristosvo commented Jan 4, 2022

Fixes #14691

Acceptance Tests

Screenshot 2022-01-05 at 13 16 03

To Do:

  • Docs azurerm_mssql_outbound_firewall_rule
  • Docs azurerm_mssql_server

@aristosvo aristosvo marked this pull request as ready for review January 5, 2022 12:17
@aristosvo aristosvo added new-virtual-resource Resources which are split out to enhance the user experience service/mssql Microsoft SQL Server labels Jan 5, 2022
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aristosvo - looks like this is missing docs.. also shouldn't there be more properties for a firewall rule 🤔

@aristosvo
Copy link
Collaborator Author

@katbyte These are the options from the Portal:

I'll add docs tonight!

@katbyte
Copy link
Collaborator

katbyte commented Jan 7, 2022

Hmm, it seems like this is a per server setting - ie 1:1 for the resource, and just flips a boolean setting for that server?

maybe this would be best as a restrict_outbound_networking property on the server rather than a separate resource?

@aristosvo
Copy link
Collaborator Author

aristosvo commented Jan 7, 2022

It's two kind of settings:

  • a switch on server level to restrict outbound traffic
  • a list of FQDNs which are allowed to receive traffic (the actual firewall rules)

My thinking was to mimic inbound firewall rules setup, which has:

  • a switch on server level to restrict inbound traffic
  • a separate resource for the rules, the firewall rules resource

Like this:

# option 1
resource "azurerm_mssql_server" "test" {
  name                         = "acctestsqlserver%[1]d"
  resource_group_name          = azurerm_resource_group.test.name
  location                     = azurerm_resource_group.test.location
  version                      = "12.0"
  administrator_login          = "msincredible"
  administrator_login_password = "P@55W0rD!!%[3]s"

  outbound_network_restriction_enabled = true # new boolean to restrict outbound network
}

# Allows traffic to 'sql%[2]d.database.windows.net'
 resource "azurerm_mssql_outbound_firewall_rule" "test" {
   name      = "sql%[2]d.database.windows.net"
   server_id = azurerm_mssql_server.test.id
 }

I'll happily change it if necessary, I just mimicked the structure for inbound firewall rules. Your suggestion would result in this structure:

resource "azurerm_mssql_server" "test" {
  name                         = "acctestsqlserver%[1]d"
  resource_group_name          = azurerm_resource_group.test.name
  location                     = azurerm_resource_group.test.location
  version                      = "12.0"
  administrator_login          = "msincredible"
  administrator_login_password = "P@55W0rD!!%[3]s"

  # option 2a
  outbound_network_restriction {
   enabled      = true # new boolean to restrict outbound network, can be made implicit
   fqdns_allowed = [ "sql%[2]d.database.windows.net", "test.example.com" ]
  }
  # or option 2b
  # outbound_network_restriction_fqdn_exceptions = [ "sql%[2]d.database.windows.net", "test.example.com" ]
}

Do you prefer the latter implementation (2a/2b)?

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer 2b but given inbound already behaves this way so be it for consistency! thanks @aristosvo - LBTM 🚀

@katbyte katbyte merged commit 4f7f4f1 into hashicorp:main Feb 16, 2022
katbyte added a commit that referenced this pull request Feb 16, 2022
@github-actions github-actions bot added this to the v2.97.0 milestone Feb 16, 2022
stephybun pushed a commit that referenced this pull request Feb 16, 2022
@github-actions
Copy link

This functionality has been released in v2.97.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation new-virtual-resource Resources which are split out to enhance the user experience service/mssql Microsoft SQL Server size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Azure SQL Outbound Firewall rules
2 participants