Unable to use "encryption_at_host_enabled" in terraform code,

Hello everyone,
I am trying to implement “encryption_at_host_enabled” in my terraform script.

storage_os_disk {
name = “osdisk-{var.vm_hostname}-{count.index}”
create_option = “FromImage”
caching = “ReadWrite”
managed_disk_type = var.storage_account_type
encryption_at_host_enabled = true
}

dynamic storage_data_disk {
for_each = range(var.nb_data_disk)
content {
name = “{var.vm_hostname}-datadisk-{count.index}-${storage_data_disk.value}”
create_option = “Empty”
lun = storage_data_disk.value
disk_size_gb = var.data_disk_size_gb
managed_disk_type = var.data_sa_type
encryption_at_host_enabled = true
}
}

dynamic storage_data_disk {
for_each = var.extra_disks
content {
name = “{var.vm_hostname}-extradisk-{count.index}-${storage_data_disk.value.name}”
create_option = “Empty”
lun = storage_data_disk.key + var.nb_data_disk
disk_size_gb = storage_data_disk.value.size
managed_disk_type = var.data_sa_type
encryption_at_host_enabled = true
}
But getting the error

Error: Unsupported argument

on main.tf line 73, in resource “azurerm_virtual_machine” “vm-linux”:
73: encryption_at_host_enabled = true

An argument named “encryption_at_host_enabled” is not expected here.

Error: Unsupported argument

on main.tf line 84, in resource “azurerm_virtual_machine” “vm-linux”:
84: encryption_at_host_enabled = true

An argument named “encryption_at_host_enabled” is not expected here.

Error: Unsupported argument

on main.tf line 96, in resource “azurerm_virtual_machine” “vm-linux”:
96: encryption_at_host_enabled = true

An argument named “encryption_at_host_enabled” is not expected here.

ERRO[0011] 1 error occurred:
* exit status 1

Please help to resolve the issue

Please see my reply to the similar question posted in the Terraform category.

The azurerm_virtual_machine resource does not support that argument. You will need to change your module to use the (newer) azurerm_linux_virtual_machine resource which does support it.

How to implement “encryption_at_host_enabled” using terraform - Terraform - HashiCorp Discuss