Azure Database SQL Server Server Transparent Data Encryption
This page shows how to write Terraform and Azure Resource Manager for Database SQL Server Server Transparent Data Encryption and write them securely.
azurerm_mssql_server_transparent_data_encryption (Terraform)
The SQL Server Server Transparent Data Encryption in Database can be configured in Terraform with the resource name azurerm_mssql_server_transparent_data_encryption
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_mssql_server_transparent_data_encryption" "service-managed" {
server_id = azurerm_mssql_server.db-server.id
resource "azurerm_mssql_server_transparent_data_encryption" "encryption" {
server_id = azurerm_mssql_server.sqldb_server.id
resource "azurerm_mssql_server_transparent_data_encryption" "db" {
server_id = azurerm_mssql_server.db.id
}
resource "azurerm_mssql_virtual_network_rule" "db" {
name = "tf-db-vnet"
resource "azurerm_mssql_server_transparent_data_encryption" "tde" {
count = try(var.settings.transparent_data_encryption.enable, false) ? 1 : 0
server_id = azurerm_mssql_server.mssql.id
key_vault_key_id = try(var.settings.transparent_data_encryption.encryption_key, null) == null ? null : coalesce(
try(var.remote_objects.keyvault_keys[var.settings.transparent_data_encryption.encryption_key.lz_key][var.settings.transparent_data_encryption.encryption_key.keyvault_key_key].id, null),
Parameters
The following arguments are supported:
server_id
- (Required) Specifies the name of the MS SQL Server.
key_vault_key_id
- (Optional) To use customer managed keys from Azure Key Vault, provide the AKV Key ID. To use service managed keys, omit this field.
NOTE: In order to use customer managed keys, the identity of the MSSQL server must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey'
In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the MSSQL encryption protector
Explanation in Terraform Registry
Manages the transparent data encryption configuration for a MSSQL Server
NOTE: Once transparent data encryption is enabled on a MS SQL instance, it is not possible to remove TDE. You will be able to switch between 'ServiceManaged' and 'CustomerManaged' keys, but will not be able to remove encryption. For safety when this resource is deleted, the TDE mode will automatically be set to 'ServiceManaged'. See
key_vault_uri
for more information on how to specify the key types. As SQL Server only supports a single configuration for encryption settings, this resource will replace the current encryption settings on the server.Note: See documentation for important information on how handle lifecycle management of the keys to prevent data lockout.
Tips: Best Practices for The Other Azure Database Resources
In addition to the azurerm_mariadb_firewall_rule, Azure Database has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_mariadb_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_mariadb_server
Ensure that access to Azure SQL Database is restricted
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_mssql_database_extended_auditing_policy
Ensure to configure retention periods of database auditing to enough duration
It is better to configure retention periods of database auditing to enough duration. It would be better to set greater than at least 90 days.
azurerm_mssql_server
Ensure to enable auditing on Azure SQL databases
It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.
azurerm_mssql_server_security_alert_policy
Ensure to configure at least one email address for threat alerts
It is better to configure at least one email address for threat alerts. SQL Server is able to send alerts for threat detection via emails and it could support us to notice the incident on time.
azurerm_mysql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_mysql_server
Ensure to disable public access to database
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_postgresql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_postgresql_server
Ensure to disable public access to database
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_sql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_sql_server
Ensure to enable auditing on Azure SQL databases
It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.
Microsoft.Sql/servers/encryptionProtector/current (Azure Resource Manager)
The servers/encryptionProtector/current in Microsoft.Sql can be configured in Azure Resource Manager with the resource name Microsoft.Sql/servers/encryptionProtector/current
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Frequently asked questions
What is Azure Database SQL Server Server Transparent Data Encryption?
Azure Database SQL Server Server Transparent Data Encryption is a resource for Database of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Database SQL Server Server Transparent Data Encryption?
For Terraform, the gayatri1030/azuresqlserver, badgerowluke/swo-newnextjuly2021 and tarwn/example-lob-app source code examples are useful. See the Terraform Example section for further details.