Azure Database SQL Elasticpool
This page shows how to write Terraform and Azure Resource Manager for Database SQL Elasticpool and write them securely.
azurerm_sql_elasticpool (Terraform)
The SQL Elasticpool in Database can be configured in Terraform with the resource name azurerm_sql_elasticpool
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_sql_elasticpool" "sqlelasticpool" {
name = "azsqlelasticpooltf"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
server_name = azurerm_sql_server.sqlserverelastic.name
edition = "Basic"
resource "azurerm_sql_elasticpool" "sqlelasticpool" {
name = "azsqlelasticpooltf"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
server_name = azurerm_sql_server.sqlserver.name
edition = "Basic"
resource "azurerm_sql_elasticpool" "this" {
db_dtu_max = var.db_dtu_max
db_dtu_min = var.db_dtu_min
dtu = var.dtu
edition = var.edition
location = var.location
resource "azurerm_sql_elasticpool" "this" {
db_dtu_max = var.db_dtu_max
db_dtu_min = var.db_dtu_min
dtu = var.dtu
edition = var.edition
location = var.location
resource "azurerm_sql_elasticpool" "elasticpool" {
count = length(var.elasticpool)
dtu = lookup(var.elasticpool[count.index], "dtu")
db_dtu_max = lookup(var.elasticpool[count.index], "db_dtu_max")
db_dtu_min = lookup(var.elasticpool[count.index], "db_dtu_min")
pool_size = lookup(var.elasticpool[count.index], "pool_size")
resource "azurerm_sql_elasticpool" "sqlelasticpoolmyfirstdne" {
server_name = azurerm_sql_server.sqlservermyfirstdne.name
location = azurerm_resource_group.rgmyfirstdne.location
resource_group_name = azurerm_resource_group.rgmyfirstdne.name
dtu = "50"
name = format("%s%s", azurerm_resource_group.rgmyfirstdne.name, "dotnetsqlelasticpool")
resource "azurerm_sql_elasticpool" "this" {
# db_dtu_max - (optional) is a type of number
db_dtu_max = var.db_dtu_max
# db_dtu_min - (optional) is a type of number
db_dtu_min = var.db_dtu_min
# dtu - (required) is a type of number
resource "azurerm_sql_elasticpool" "example" {
name = var.elasticpool_name
resource_group_name = local.resource_group.name
location = local.resource_group.location
server_name = azurerm_sql_server.server.name
edition = var.elasticpool_edition
resource "azurerm_sql_elasticpool" "sql_server_elastic_pool" {
## create only if elastic_pool object is filled
for_each = var.sql_server.elastic_pool
## dependencies in order for changes not to be concurrent on the object and get an error
depends_on = [azurerm_sql_virtual_network_rule.sql_vnet_rule, azurerm_sql_active_directory_administrator.admins]
resource "azurerm_sql_elasticpool" "az_elasticpool" {
count = var.az_sql_elasticpool_name != null ? 1 : 0
name = var.az_sql_elasticpool_name
resource_group_name = var.resource_group_name
location = var.location
server_name = azurerm_sql_server.az_sql_server.name
Parameters
-
creation_date
optional computed - string -
db_dtu_max
optional computed - number -
db_dtu_min
optional computed - number -
dtu
required - number -
edition
required - string -
id
optional computed - string -
location
required - string -
name
required - string -
pool_size
optional computed - number -
resource_group_name
required - string -
server_name
required - string -
tags
optional - map from string to string -
timeouts
single block
Explanation in Terraform Registry
Allows you to manage an Azure SQL Elastic Pool.
NOTE: - This version of the
Elasticpool
resource is being deprecated and should no longer be used. Please use the azurerm_mssql_elasticpool version instead.
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/elasticPools (Azure Resource Manager)
The servers/elasticPools in Microsoft.Sql can be configured in Azure Resource Manager with the resource name Microsoft.Sql/servers/elasticPools
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"properties": {
"creationDate": "2017-02-10T01:27:21.32Z",
"edition": "Basic",
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resource_prefix": {
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"properties": {
"creationDate": "2017-02-10T01:27:21.32Z",
"edition": "Basic",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"sku": {
"name": "GP_Gen4_2",
"tier": "GeneralPurpose",
"type": "Microsoft.Sql/servers/elasticPools"
},
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-2369/providers/Microsoft.Sql/servers/sqlcrudtest-8069/elasticPools/sqlcrudtest-3191",
"kind": null,
"location": "Japan East",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"properties": {
"creationDate": "2017-02-10T01:27:21.32Z",
"edition": "Basic",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"properties": {
"creationDate": "2017-02-10T01:27:21.32Z",
"edition": "Basic",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"sku": {
"name": "GP_Gen4_2",
"tier": "GeneralPurpose",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"properties": {
"creationDate": "2017-02-10T01:27:21.32Z",
"edition": "Basic",
"type": "Microsoft.Sql/servers/elasticPools",
"location": "Japan East",
"kind": null,
"sku": {
"name": "GP_Gen4_2",
"tier": "GeneralPurpose",
Parameters
apiVersion
required - stringlocation
required - stringResource location.
name
required - stringThe name of the elastic pool to be operated on (updated or created).
properties
requireddatabaseDtuMax
optional - integerThe maximum DTU any one database can consume.
databaseDtuMin
optional - integerThe minimum DTU all databases are guaranteed.
dtu
optional - integerThe total shared DTU for the database elastic pool.
edition
optional - stringThe edition of the elastic pool.
storageMB
optional - integerGets storage limit for the database elastic pool in MB.
zoneRedundant
optional - booleanWhether or not this database elastic pool is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
tags
optional - stringResource tags.
type
required - string
Frequently asked questions
What is Azure Database SQL Elasticpool?
Azure Database SQL Elasticpool 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 Elasticpool?
For Terraform, the leoviana00/iac-azure-terraform, higorbarbosa/treinamento-terraform-azure and kevinhead/azurerm source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the rajithanitc/arm-resourcehealthswagger, QuanTomiZaH/Configuration-Tools and assing/alerts-extension source code examples are useful. See the Azure Resource Manager Example section for further details.