Skip to content

azurermMssqlElasticpool

Allows you to manage an Azure SQL Elastic Pool via the v30 API which allows for vCore and dtu based configurations.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "my-resource-group",
  }
);
const azurermSqlServerExample = new azurerm.sqlServer.SqlServer(
  this,
  "example_1",
  {
    administrator_login: "4dm1n157r470r",
    administrator_login_password: "4-v3ry-53cr37-p455w0rd",
    location: azurermResourceGroupExample.location,
    name: "my-sql-server",
    resource_group_name: azurermResourceGroupExample.name,
    version: "12.0",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSqlServerExample.overrideLogicalId("example");
const azurermMssqlElasticpoolExample =
  new azurerm.mssqlElasticpool.MssqlElasticpool(this, "example_2", {
    license_type: "LicenseIncluded",
    location: azurermResourceGroupExample.location,
    max_size_gb: 756,
    name: "test-epool",
    per_database_settings: [
      {
        max_capacity: 4,
        min_capacity: 0.25,
      },
    ],
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermSqlServerExample.name,
    sku: [
      {
        capacity: 4,
        family: "Gen4",
        name: "BasicPool",
        tier: "Basic",
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMssqlElasticpoolExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the elastic pool. This needs to be globally unique. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the elastic pool. This must be the same as the resource group of the underlying SQL server. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • serverName - (Required) The name of the SQL Server on which to create the elastic pool. Changing this forces a new resource to be created.

  • sku - (Required) A sku block as defined below.

  • perDatabaseSettings - (Required) A perDatabaseSettings block as defined below.

  • maintenanceConfigurationName - (Optional) The name of the Public Maintenance Configuration window to apply to the elastic pool. Valid values include sqlDefault, sqlEastUsDb1, sqlEastUs2Db1, sqlSoutheastAsiaDb1, sqlAustraliaEastDb1, sqlNorthEuropeDb1, sqlSouthCentralUsDb1, sqlWestUs2Db1, sqlUkSouthDb1, sqlWestEuropeDb1, sqlEastUsDb2, sqlEastUs2Db2, sqlWestUs2Db2, sqlSoutheastAsiaDb2, sqlAustraliaEastDb2, sqlNorthEuropeDb2, sqlSouthCentralUsDb2, sqlUkSouthDb2, sqlWestEuropeDb2, sqlAustraliaSoutheastDb1, sqlBrazilSouthDb1, sqlCanadaCentralDb1, sqlCanadaEastDb1, sqlCentralUsDb1, sqlEastAsiaDb1, sqlFranceCentralDb1, sqlGermanyWestCentralDb1, sqlCentralIndiaDb1, sqlSouthIndiaDb1, sqlJapanEastDb1, sqlJapanWestDb1, sqlNorthCentralUsDb1, sqlUkWestDb1, sqlWestUsDb1, sqlAustraliaSoutheastDb2, sqlBrazilSouthDb2, sqlCanadaCentralDb2, sqlCanadaEastDb2, sqlCentralUsDb2, sqlEastAsiaDb2, sqlFranceCentralDb2, sqlGermanyWestCentralDb2, sqlCentralIndiaDb2, sqlSouthIndiaDb2, sqlJapanEastDb2, sqlJapanWestDb2, sqlNorthCentralUsDb2, sqlUkWestDb2, sqlWestUsDb2, sqlWestCentralUsDb1, sqlFranceSouthDb1, sqlWestCentralUsDb2, sqlFranceSouthDb2, sqlSwitzerlandNorthDb1, sqlSwitzerlandNorthDb2, sqlBrazilSoutheastDb1, sqlUaeNorthDb1, sqlBrazilSoutheastDb2, sqlUaeNorthDb2. Defaults to sqlDefault.

  • maxSizeGb - (Optional) The max data size of the elastic pool in gigabytes. Conflicts with maxSizeBytes.

  • maxSizeBytes - (Optional) The max data size of the elastic pool in bytes. Conflicts with maxSizeGb.

-> Note: One of either maxSizeGb or maxSizeBytes must be specified.

  • tags - (Optional) A mapping of tags to assign to the resource.

  • zoneRedundant - (Optional) Whether or not this elastic pool is zone redundant. tier needs to be premium for dtu based or businessCritical for vCore based sku.

  • licenseType - (Optional) Specifies the license type applied to this database. Possible values are licenseIncluded and basePrice.

-> Note: licenseType can only be configured when sku0Tier is set to generalPurpose or businessCritical


The sku block supports the following:

  • name - (Required) Specifies the SKU Name for this Elasticpool. The name of the SKU, will be either vCore based tier + family pattern (e.g. GP_Gen4, BC_Gen5) or the dtu based basicPool, standardPool, or premiumPool pattern. Possible values are basicPool, standardPool, premiumPool, gpGen4, gpGen5, gpFsv2, gpDc, bcGen4, bcGen5 and bcDc.

  • capacity - (Required) The scale up/out capacity, representing server's compute units. For more information see the documentation for your Elasticpool configuration: vCore-based or DTU-based.

  • tier - (Required) The tier of the particular SKU. Possible values are generalPurpose, businessCritical, basic, standard, or premium. For more information see the documentation for your Elasticpool configuration: vCore-based or DTU-based.

  • family - (Optional) The family of hardware gen4, gen5, fsv2 or dc.


The perDatabaseSettings block supports the following:

  • minCapacity - (Required) The minimum capacity all databases are guaranteed.

  • maxCapacity - (Required) The maximum capacity any one database can consume.


Attributes Reference

The following attributes are exported:

  • id - The ID of the MS SQL Elastic Pool.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the MS SQL Elastic Pool.
  • update - (Defaults to 30 minutes) Used when updating the MS SQL Elastic Pool.
  • read - (Defaults to 5 minutes) Used when retrieving the MS SQL Elastic Pool.
  • delete - (Defaults to 30 minutes) Used when deleting the MS SQL Elastic Pool.

Import

SQL Elastic Pool can be imported using the resourceId, e.g.

terraform import azurerm_mssql_elasticpool.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver/elasticPools/myelasticpoolname