Skip to content

azurermMysqlActiveDirectoryAdministrator

Allows you to set a user or group as the AD administrator for an MySQL server in Azure

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: "example-resources",
  }
);
const dataAzurermClientConfigCurrent =
  new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
    this,
    "current",
    {}
  );
const azurermMysqlServerExample = new azurerm.mysqlServer.MysqlServer(
  this,
  "example_2",
  {
    administrator_login: "mysqladminun",
    administrator_login_password: "H@Sh1CoR3!",
    location: azurermResourceGroupExample.location,
    name: "example-mysqlserver",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "B_Gen5_2",
    ssl_enforcement_enabled: true,
    storage_mb: 5120,
    version: "5.7",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlServerExample.overrideLogicalId("example");
const azurermMysqlActiveDirectoryAdministratorExample =
  new azurerm.mysqlActiveDirectoryAdministrator.MysqlActiveDirectoryAdministrator(
    this,
    "example_3",
    {
      login: "sqladmin",
      object_id: dataAzurermClientConfigCurrent.objectId,
      resource_group_name: azurermResourceGroupExample.name,
      server_name: azurermMysqlServerExample.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.*/
azurermMysqlActiveDirectoryAdministratorExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • serverName - (Required) The name of the MySQL Server 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 MySQL server. Changing this forces a new resource to be created.

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

  • objectId - (Required) The ID of the principal to set as the server administrator. For a managed identity this should be the Client ID of the identity.

  • tenantId - (Required) The Azure Tenant ID

Attributes Reference

The following attributes are exported:

  • id - The ID of the MySQL Active Directory Administrator.

Timeouts

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

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

Import

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

terraform import azurerm_mysql_active_directory_administrator.administrator /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforMySQL/servers/myserver/administrators/activeDirectory