Skip to content

azurermSqlManagedInstanceFailoverGroup

Manages a SQL Instance Failover Group.

Example Usage

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

\~> Note: For a more complete example, see the the examples/sqlAzure/managedInstanceFailoverGroup directory within the GitHub Repository.

/*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.*/
new azurerm.resourceGroup.ResourceGroup(this, "example", {
  location: "West Europe",
  name: "rg-example",
});
const azurermSqlManagedInstancePrimary =
  new azurerm.sqlManagedInstance.SqlManagedInstance(this, "primary", {
    administrator_login: "mradministrator",
    administrator_login_password: "thisIsDog11",
    depends_on: [
      "${azurerm_subnet_network_security_group_association.primary}",
      "${azurerm_subnet_route_table_association.primary}",
    ],
    license_type: "BasePrice",
    location: "${azurerm_resource_group.primary.location}",
    name: "example-primary",
    resource_group_name: "${azurerm_resource_group.primary.name}",
    sku_name: "GP_Gen5",
    storage_size_in_gb: 32,
    subnet_id: "${azurerm_subnet.primary.id}",
    tags: {
      environment: "prod",
    },
    vcores: 4,
  });
const azurermSqlManagedInstanceSecondary =
  new azurerm.sqlManagedInstance.SqlManagedInstance(this, "secondary", {
    administrator_login: "mradministrator",
    administrator_login_password: "thisIsDog11",
    depends_on: [
      "${azurerm_subnet_network_security_group_association.secondary}",
      "${azurerm_subnet_route_table_association.secondary}",
    ],
    license_type: "BasePrice",
    location: "${azurerm_resource_group.secondary.location}",
    name: "example-secondary",
    resource_group_name: "${azurerm_resource_group.secondary.name}",
    sku_name: "GP_Gen5",
    storage_size_in_gb: 32,
    subnet_id: "${azurerm_subnet.secondary.id}",
    tags: {
      environment: "prod",
    },
    vcores: 4,
  });
const azurermSqlManagedInstanceFailoverGroupExample =
  new azurerm.sqlManagedInstanceFailoverGroup.SqlManagedInstanceFailoverGroup(
    this,
    "example_3",
    {
      location: azurermSqlManagedInstancePrimary.location,
      managed_instance_name: azurermSqlManagedInstancePrimary.name,
      name: "example-failover-group",
      partner_managed_instance_id: azurermSqlManagedInstanceSecondary.id,
      read_write_endpoint_failover_policy: [
        {
          grace_minutes: 60,
          mode: "Automatic",
        },
      ],
      resource_group_name: "${azurerm_resource_group.primary.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.*/
azurermSqlManagedInstanceFailoverGroupExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this SQL Instance Failover Group. Changing this forces a new SQL Instance Failover Group to be created.

  • managedInstanceName - (Required) The name of the SQL Managed Instance which will be replicated using a SQL Instance Failover Group. Changing this forces a new SQL Instance Failover Group to be created.

  • location - (Required) The Azure Region where the SQL Instance Failover Group exists. Changing this forces a new resource to be created.

  • partnerManagedInstanceId - (Required) ID of the SQL Managed Instance which will be replicated to. Changing this forces a new resource to be created.

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

  • resourceGroupName - (Required) The name of the Resource Group where the SQL Instance Failover Group should exist. Changing this forces a new SQL Instance Failover Group to be created.

  • readonlyEndpointFailoverPolicyEnabled - (Optional) Failover policy for the read-only endpoint. Defaults to true.


A readWriteEndpointFailoverPolicy block supports the following:

  • mode - (Required) The failover mode. Possible values are manual, automatic

  • graceMinutes - (Optional) Applies only if mode is automatic. The grace period in minutes before failover with data loss is attempted.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the SQL Instance Failover Group.

  • partnerRegion - A partnerRegion block as defined below.

  • role - The local replication role of the SQL Instance Failover Group.


A partnerRegion block exports the following:

  • location - The Azure Region where the SQL Instance Failover Group partner exists.

  • role - The partner replication role of the SQL Instance Failover Group.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the SQL Instance Failover Group.
  • read - (Defaults to 5 minutes) Used when retrieving the SQL Instance Failover Group.
  • update - (Defaults to 30 minutes) Used when updating the SQL Instance Failover Group.
  • delete - (Defaults to 30 minutes) Used when deleting the SQL Instance Failover Group.

Import

SQL Instance Failover Groups can be imported using the resourceId, e.g.

terraform import azurerm_sql_managed_instance_failover_group.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Sql/locations/Location/instanceFailoverGroups/failoverGroup1