Skip to content

azurermSqlManagedInstanceActiveDirectoryAdministrator

Allows you to set a user or group as the AD administrator for an Azure SQL Managed Instance.

-> Note: The azurermSqlManagedInstanceActiveDirectoryAdministrator resource is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the azurermMssqlManagedInstanceActiveDirectoryAdministrator 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 azurermSqlManagedInstanceExample =
  new azurerm.sqlManagedInstance.SqlManagedInstance(this, "example_1", {
    administrator_login: "mradministrator",
    administrator_login_password: "thisIsDog11",
    depends_on: [
      "${azurerm_subnet_network_security_group_association.example}",
      "${azurerm_subnet_route_table_association.example}",
    ],
    license_type: "BasePrice",
    location: azurermResourceGroupExample.location,
    name: "managedsqlinstance",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "GP_Gen5",
    storage_size_in_gb: 32,
    subnet_id: "${azurerm_subnet.example.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 dataAzurermClientConfigCurrent =
  new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
    this,
    "current",
    {}
  );
const azurermSqlManagedInstanceActiveDirectoryAdministratorExample =
  new azurerm.sqlManagedInstanceActiveDirectoryAdministrator.SqlManagedInstanceActiveDirectoryAdministrator(
    this,
    "example_3",
    {
      login: "sqladmin",
      managed_instance_name: azurermSqlManagedInstanceExample.name,
      object_id: dataAzurermClientConfigCurrent.objectId,
      resource_group_name: azurermResourceGroupExample.name,
      tenant_id: dataAzurermClientConfigCurrent.tenantId,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSqlManagedInstanceActiveDirectoryAdministratorExample.overrideLogicalId(
  "example"
);

Argument Reference

The following arguments are supported:

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

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

  • login - (Required) The login name of the principal to set as the Managed Instance administrator

  • objectId - (Required) The ID of the principal to set as the Managed Instance administrator

  • tenantId - (Required) The Azure Tenant ID

  • azureadAuthenticationOnly - (Optional) Specifies whether only AD Users and administrators can be used to login (true) or also local database users (false). Defaults to false.

Attributes Reference

The following attributes are exported:

  • id - The ID of the SQL Managed Instance Active Directory Administrator.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the SQL Active Directory Administrator.
  • update - (Defaults to 30 minutes) Used when updating the SQL Active Directory Administrator.
  • read - (Defaults to 5 minutes) Used when retrieving the SQL Active Directory Administrator.
  • delete - (Defaults to 30 minutes) Used when deleting the SQL Active Directory Administrator.

Import

A SQL Active Directory Administrator can be imported using the resourceId, e.g.

terraform import azurerm_sql_managed_instance_active_directory_administrator.administrator /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/managedInstances/mymanagedinstance/administrators/activeDirectory