Open dharmendar11 opened 1 year ago
@rcskosir Any update on the above issue.
Running into this error too. Anyone has any workaround please?
@DongXue-Trimble The workaround I tried is to run a PowerShell script in Terraform using the null_resource resource block of Terraform.
I tried azurerm_virtual_machine
because azurerm_windows_virtual_machine is required admin_username and admin_password and Specialized
images do not accept admin_username and admin_password.
Could you tell me any workaround?
@s-nakagaki The workaround I tried is to run a PowerShell script in Terraform using the null_resource resource block of Terraform.
The workaround I tried is to run a PowerShell script in Terraform using the null_resource resource block of Terraform.
thanks, dharmendar11.
You mean az
command with null_resource?
If so, sounds not like a workaround.
But your way is one of solution for this issue.
if az
command solves it, I think azapi
solves it too.
In your terraform code, when you want to create a Linux VM, you can use the following code:
variable "Ubuntu22_CIS_Agent" {
default ="/subscriptions/xxxxxx/resourceGroups/your_resource/providers/Microsoft.Compute/galleries/your_img_gallery/images/Ubuntu22_CIS/versions/1.0.0"
}
resource "azurerm_linux_virtual_machine" "vm-test" {
name ="vm-test"
# (resource arguments)
resource_group_name = data.azurerm_resource_group.your_resource.name
location = data.azurerm_resource_group.your_resource.location
size = "Standard_B1s"
admin_username = "azureuser"
network_interface_ids = [
azurerm_network_interface.your_nic_name.id,,
]
os_disk {
caching = "None"
storage_account_type = "Premium_LRS"
}
source_image_id = var.Ubuntu22_CIS_Agent
secure_boot_enabled = true
vtpm_enabled = true
encryption_at_host_enabled =false
}
In your terraform code, when you want to create a Linux VM, you can use the following code:
variable "Ubuntu22_CIS_Agent" {
default ="/subscriptions/xxxxxx/resourceGroups/your_resource/providers/Microsoft.Compute/galleries/your_img_gallery/images/Ubuntu22_CIS/versions/1.0.0"
}
resource "azurerm_linux_virtual_machine" "vm-test" {
name ="vm-test"
# (resource arguments)
resource_group_name = data.azurerm_resource_group.your_resource.name
location = data.azurerm_resource_group.your_resource.location
size = "Standard_B1s"
admin_username = "azureuser"
network_interface_ids = [
azurerm_network_interface.your_nic_name.id,,
]
os_disk {
caching = "None"
storage_account_type = "Premium_LRS"
}
source_image_id = var.Ubuntu22_CIS_Agent
secure_boot_enabled = true
vtpm_enabled = true
encryption_at_host_enabled =false
}
Is there an existing issue for this?
Community Note
Terraform Version
1.5.3
AzureRM Provider Version
3.65.0
Affected Resource(s)/Data Source(s)
azurerm_virtual_machine
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
A new VM should be created from the gallery image.
Actual Behaviour
When trying to create a VM with a gallery image using Terraform got the error "The provided gallery image only supports creation of VMs and VM Scale Sets with 'TrustedLaunch' security type."
Although the image is created using a Trusted launch and there is no option to add code to the terraform script for Trusted Lunch (Tried security_type - An argument named "security_type" is not expected here, trusted_launch_enabled - An argument named "trusted_launch_enabled" is not expected here, extended_security_configuration - Blocks of type "extended_security_configuration" are not expected here) after applying all 3 options still no luck.
Steps to Reproduce
No response
Important Factoids
No response
References
No response