Skip to content

azurermSqlManagedDatabase

Manages a SQL Azure Managed Database.

-> Note: The azurermSqlManagedDatabase resource is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the azurermMssqlManagedDatabase resource instead.

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: "rg-example",
  }
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "test-network",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_2", {
  address_prefixes: ["10.0.2.0/24"],
  name: "acctsub",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermSqlManagedInstanceExample =
  new azurerm.sqlManagedInstance.SqlManagedInstance(this, "example_3", {
    administrator_login: "mradministrator",
    administrator_login_password: "thisIsDog11",
    license_type: "BasePrice",
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "GP_Gen5",
    storage_size_in_gb: 32,
    subnet_id: azurermSubnetExample.id,
    vcores: 4,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSqlManagedInstanceExample.overrideLogicalId("example");
const azurermSqlManagedDatabaseExample =
  new azurerm.sqlManagedDatabase.SqlManagedDatabase(this, "example_4", {
    location: azurermResourceGroupExample.location,
    name: "exampledatabase",
    sql_managed_instance_id: azurermSqlManagedInstanceExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSqlManagedDatabaseExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the SQL Managed Instance. Changing this forces a new resource to be created.

  • sqlManagedInstanceId - (Required) The SQL Managed Instance ID that this Managed Database will be associated with. 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.


The following attributes are exported:

  • id - The SQL Managed Database ID.

Timeouts

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

  • read - (Defaults to 5 minutes) Used when retrieving the Sql Managed Database.
  • create - (Defaults to 24 hours) Used when creating the Sql Managed Database.
  • update - (Defaults to 24 hours) Used when updating the Sql Managed Database.
  • delete - (Defaults to 24 hours) Used when deleting the Sql Managed Database.

Import

SQL Managed Databases can be imported using the resourceId, e.g.

terraform import azurerm_sql_managed_database.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/managedInstances/myserver/databases/mydatabase