azurermMssqlManagedInstanceActiveDirectoryAdministrator
Allows you to set a user, group or service principal as the AAD Administrator for an Azure SQL Managed Instance.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azuread from "./.gen/providers/azuread";
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azuread, azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azureadDirectoryRoleReader = new azuread.directoryRole.DirectoryRole(
this,
"reader",
{
display_name: "Directory Readers",
}
);
const azureadUserAdmin = new azuread.user.User(this, "admin", {
display_name: "Ms Admin",
mail_nickname: "ms.admin",
password: "SecretP@sswd99!",
user_principal_name: "ms.admin@hashicorp.com",
});
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "rg-example",
}
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
this,
"example_3",
{
address_space: ["10.0.0.0/16"],
location: azurermResourceGroupExample.location,
name: "example",
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 dataAzurermClientConfigCurrent =
new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
this,
"current",
{}
);
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_5", {
address_prefixes: ["10.0.2.0/24"],
name: "example",
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 azurermMssqlManagedInstanceExample =
new azurerm.mssqlManagedInstance.MssqlManagedInstance(this, "example_6", {
administrator_login: "msadministrator",
administrator_login_password: "thisIsDog11",
identity: [
{
type: "SystemAssigned",
},
],
license_type: "BasePrice",
location: azurermResourceGroupExample.location,
name: "managedsqlinstance",
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.*/
azurermMssqlManagedInstanceExample.overrideLogicalId("example");
const azurermMssqlManagedInstanceActiveDirectoryAdministratorExample =
new azurerm.mssqlManagedInstanceActiveDirectoryAdministrator.MssqlManagedInstanceActiveDirectoryAdministrator(
this,
"example_7",
{
login_username: "msadmin",
managed_instance_id: azurermMssqlManagedInstanceExample.id,
object_id: azureadUserAdmin.objectId,
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.*/
azurermMssqlManagedInstanceActiveDirectoryAdministratorExample.overrideLogicalId(
"example"
);
const azureadDirectoryRoleMemberExample =
new azuread.directoryRoleMember.DirectoryRoleMember(this, "example_8", {
member_object_id: `\${${azurermMssqlManagedInstanceExample.identity}.0.principal_id}`,
role_object_id: azureadDirectoryRoleReader.objectId,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azureadDirectoryRoleMemberExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
-
managedInstanceId
- (Required) The ID of the Azure SQL Managed Instance for which to set the administrator. Changing this forces a new resource to be created. -
loginUsername
- (Required) The login name of the principal to set as the Managed Instance Administrator. -
objectId
- (Required) The Object ID of the principal to set as the Managed Instance Administrator. -
tenantId
- (Required) The Azure Active Directory Tenant ID. -
azureadAuthenticationOnly
- (Optional) Whentrue
, only permit logins from AAD users and administrators. Whenfalse
, also allow local database users.
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
An Azure SQL Active Directory Administrator can be imported using the resourceId
, e.g.