I’m putting these here so I don’t forget how to properly format these resources. My future me will be pleased about this at some point.
resource "azurerm_virtual_machine_extension" "dsc" {
count = var.compute_instance_count
name = "TestDSC"
virtual_machine_id = element(azurerm_virtual_machine.compute.*.id, count.index)
publisher = "Microsoft.Powershell"
type = "DSC"
type_handler_version = "2.80"
settings = <<SETTINGS
{
"WmfVersion": "latest",
"Privacy": {
"DataCollection": ""
},
"Properties": {
"RegistrationKey": {
"UserName": "PLACEHOLDER_DONOTUSE",
"Password": "PrivateSettingsRef:registrationKeyPrivate"
},
"RegistrationUrl": "${var.dsc_endpoint}",
"NodeConfigurationName": "${var.dsc_config}",
"ConfigurationMode": "${var.dsc_mode}",
"ConfigurationModeFrequencyMins": 15,
"RefreshFrequencyMins": 30,
"RebootNodeIfNeeded": false,
"ActionAfterReboot": "continueConfiguration",
"AllowModuleOverwrite": false
}
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"Items": {
"registrationKeyPrivate" : "${var.dsc_key}"
}
}
PROTECTED_SETTINGS
}
resource "azurerm_virtual_machine_extension" "joindomain" {
count = var.compute_instance_count
name = "joindomain"
virtual_machine_id = element(azurerm_virtual_machine.compute.*.id, count.index)
publisher = "Microsoft.Compute"
type = "JsonADDomainExtension"
type_handler_version = "1.3"
settings = <<SETTINGS
{
"Name": "EXAMPLE.COM",
"User": "EXAMPLE.COM\\azureuser",
"Restart": "true",
"Options": "3"
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"Password": "F@ncyP@ssw0rd"
}
PROTECTED_SETTINGS
}