azurermMssqlVirtualMachine
Manages a Microsoft SQL Virtual Machine
Example Usage
This example provisions a brief Managed Microsoft SQL Virtual Machine. The detailed example of the azurermMssqlVirtualMachine
resource can be found in the /examples/mssql/mssqlvm
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.*/
const dataAzurermVirtualMachineExample =
new azurerm.dataAzurermVirtualMachine.DataAzurermVirtualMachine(
this,
"example",
{
name: "example-vm",
resource_group_name: "example-resources",
}
);
const azurermMssqlVirtualMachineExample =
new azurerm.mssqlVirtualMachine.MssqlVirtualMachine(this, "example_1", {
auto_patching: [
{
day_of_week: "Sunday",
maintenance_window_duration_in_minutes: 60,
maintenance_window_starting_hour: 2,
},
],
r_services_enabled: true,
sql_connectivity_port: 1433,
sql_connectivity_type: "PRIVATE",
sql_connectivity_update_password: "Password1234!",
sql_connectivity_update_username: "sqllogin",
sql_license_type: "PAYG",
virtual_machine_id: dataAzurermVirtualMachineExample.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.*/
azurermMssqlVirtualMachineExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
-
virtualMachineId
- (Required) The ID of the Virtual Machine. Changing this forces a new resource to be created. -
sqlLicenseType
- (Required) The SQL Server license type. Possible values areahub
(Azure Hybrid Benefit),dr
(Disaster Recovery), andpayg
(Pay-As-You-Go). Changing this forces a new resource to be created. -
autoBackup
- (Optional) AnautoBackup
block as defined below. This block can be added to an existing resource, but removing this block forces a new resource to be created. -
autoPatching
- (Optional) AnautoPatching
block as defined below. -
keyVaultCredential
- (Optional) (Optional) AnkeyVaultCredential
block as defined below. -
rServicesEnabled
- (Optional) Should R Services be enabled? -
sqlConnectivityPort
- (Optional) The SQL Server port. Defaults to1433
. -
sqlConnectivityType
- (Optional) The connectivity type used for this SQL Server. Possible values arelocal
,private
andpublic
. Defaults toprivate
. -
sqlConnectivityUpdatePassword
- (Optional) The SQL Server sysadmin login password. -
sqlConnectivityUpdateUsername
- (Optional) The SQL Server sysadmin login to create. -
sqlInstance
- (Optional) AsqlInstance
block as defined below. -
storageConfiguration
- (Optional) AnstorageConfiguration
block as defined below. -
assessment
- (Optional) Anassessment
block as defined below. -
tags
- (Optional) A mapping of tags to assign to the resource.
The autoBackup
block supports the following:
-
encryptionEnabled
- (Optional) Enable or disable encryption for backups. Defaults tofalse
. -
encryptionPassword
- (Optional) Encryption password to use. Must be specified when encryption is enabled. -
manualSchedule
- (Optional) AmanualSchedule
block as documented below. When this block is present, the schedule type is set tomanual
. Without this block, the schedule type is set toautomated
. -
retentionPeriodInDays
- (Required) Retention period of backups, in days. Valid values are from1
to30
. -
storageBlobEndpoint
- (Required) Blob endpoint for the storage account where backups will be kept. -
storageAccountAccessKey
- (Required) Access key for the storage account where backups will be kept. -
systemDatabasesBackupEnabled
- (Optional) Include or exclude system databases from auto backup.
The manualSchedule
block supports the following:
-
fullBackupFrequency
- (Required) Frequency of full backups. Valid values includedaily
orweekly
. -
fullBackupStartHour
- (Required) Start hour of a given day during which full backups can take place. Valid values are from0
to23
. -
fullBackupWindowInHours
- (Required) Duration of the time window of a given day during which full backups can take place, in hours. Valid values are between1
and23
. -
logBackupFrequencyInMinutes
- (Required) Frequency of log backups, in minutes. Valid values are from5
to60
. -
daysOfWeek
- (Optional) A list of days on which backup can take place. Possible values aremonday
,tuesday
,wednesday
,thursday
,friday
,saturday
andsunday
\~> NOTE: daysOfWeek
can only be specified when manualSchedule
is set to weekly
The autoPatching
block supports the following:
-
dayOfWeek
- (Required) The day of week to apply the patch on. Possible values aremonday
,tuesday
,wednesday
,thursday
,friday
,saturday
andsunday
. -
maintenanceWindowStartingHour
- (Required) The Hour, in the Virtual Machine Time-Zone when the patching maintenance window should begin. -
maintenanceWindowDurationInMinutes
- (Required) The size of the Maintenance Window in minutes.
The keyVaultCredential
block supports the following:
-
name
- (Required) The credential name. -
keyVaultUrl
- (Required) The Azure Key Vault url. Changing this forces a new resource to be created. -
servicePrincipalName
- (Required) The service principal name to access key vault. Changing this forces a new resource to be created. -
servicePrincipalSecret
- (Required) The service principal name secret to access key vault. Changing this forces a new resource to be created.
The sqlInstance
block supports the following:
-
adhocWorkloadsOptimizationEnabled
- (Optional) Specifies if the SQL Server is optimized for adhoc workloads. Possible values aretrue
andfalse
. Defaults tofalse
. -
collation
- (Optional) Collation of the SQL Server. Defaults tosqlLatin1GeneralCp1CiAs
. Changing this forces a new resource to be created. -
instantFileInitializationEnabled
- (Optional) Specifies if Instant File Initialization is enabled for the SQL Server. Possible values aretrue
andfalse
. Defaults tofalse
. Changing this forces a new resource to be created. -
lockPagesInMemoryEnabled
- (Optional) Specifies if Lock Pages in Memory is enabled for the SQL Server. Possible values aretrue
andfalse
. Defaults tofalse
. Changing this forces a new resource to be created. -
maxDop
- (Optional) Maximum Degree of Parallelism of the SQL Server. Possible values are between0
and32767
. Defaults to0
. -
maxServerMemoryMb
- (Optional) Maximum amount memory that SQL Server Memory Manager can allocate to the SQL Server process. Possible values are between128
and2147483647
Defaults to2147483647
. -
minServerMemoryMb
- (Optional) Minimum amount memory that SQL Server Memory Manager can allocate to the SQL Server process. Possible values are between0
and2147483647
Defaults to0
.
\~> NOTE: maxServerMemoryMb
must be greater than or equal to minServerMemoryMb
The storageConfiguration
block supports the following:
-
diskType
- (Required) The type of disk configuration to apply to the SQL Server. Valid values includenew
,extend
, oradd
. -
storageWorkloadType
- (Required) The type of storage workload. Valid values includegeneral
,oltp
, ordw
. -
dataSettings
- (Optional) AstorageSettings
block as defined below. -
logSettings
- (Optional) AstorageSettings
block as defined below. -
systemDbOnDataDiskEnabled
- (Optional) Specifies whether to set system databases (except tempDb) location to newly created data storage. Possible values aretrue
andfalse
. Defaults tofalse
. -
tempDbSettings
- (Optional) AntempDbSettings
as defined below.
The storageSettings
block supports the following:
-
defaultFilePath
- (Required) The SQL Server default path -
luns
- (Required) A list of Logical Unit Numbers for the disks.
The tempDbSettings
block supports the following:
-
defaultFilePath
- (Required) The SQL Server default path -
luns
- (Required) A list of Logical Unit Numbers for the disks. -
dataFileCount
- (Optional) The SQL Server default file count. This value defaults to8
-
dataFileSizeMb
- (Optional) The SQL Server default file size - This value defaults to256
-
dataFileGrowthInMb
- (Optional) The SQL Server default file size - This value defaults to512
-
logFileSizeMb
- (Optional) The SQL Server default file size - This value defaults to256
-
logFileGrowthMb
- (Optional) The SQL Server default file size - This value defaults to512
The assessment
block supports the following:
-
enabled
- (Optional) Should Assessment be enabled? Defaults totrue
. -
runImmediately
- (Optional) Should Assessment be run immediately? Defaults tofalse
. -
schedule
- (Optional) Anschedule
block as defined below.
The schedule
block supports the following:
-
weeklyInterval
- (Optional) How many weeks between assessment runs. Valid values are between1
and6
. -
monthlyOccurrence
- (Optional) How many months between assessment runs. Valid values are between1
and5
.
\~> NOTE: Either one of weeklyInterval
or monthlyOccurrence
must be specified.
-
dayOfWeek
- (Required) What day of the week the assessment will be run. Default value ismonday
. Possible values arefriday
,monday
,saturday
,sunday
,thursday
,tuesday
andwednesday
. -
startTime
- (Required) What time the assessment will be run. Must be in the formathh:mm
.
Attributes Reference
The following attributes are exported:
id
- The ID of the SQL Virtual Machine.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 60 minutes) Used when creating the Microsoft SQL Virtual Machine.update
- (Defaults to 60 minutes) Used when updating the Microsoft SQL Virtual Machine.read
- (Defaults to 5 minutes) Used when retrieving the Microsoft SQL Virtual Machine.delete
- (Defaults to 60 minutes) Used when deleting the Microsoft SQL Virtual Machine.
Import
Microsoft SQL Virtual Machines can be imported using the resourceId
, e.g.