由于SecurityType,从带有Terraform的映像启动Azure VM时出错?

62lalag4  于 2023-11-21  发布在  其他
关注(0)|答案(2)|浏览(145)

我正在尝试从安全类型设置为TrustedLaunch的Azure计算库启动VM。运行应用时收到此错误:

Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="The provided gallery image only supports creation of VMs and VM Scale Sets with 'TrustedLaunch' security type."

字符串
我在5个月前看到一篇文章说Terraform不支持设置SecurityType。这是真的吗?如果是,有人遇到过这个问题并找到了解决方法吗?
干杯
尝试搜索和查找声明security_type的选项,但没有成功

eeq64g8w

eeq64g8w1#

我尝试从Azure计算库中启动安全类型设置为TrustedLaunch的VM。我能够成功配置它。
这里我们正在处理**StatusCode=400 -- Original Error:Code=“BadRequest Message=“提供的库映像仅支持创建具有”TrustedLaunch“安全类型的VM和VM Scale Set。**如果我们更改创建的映像的状态并使用Powershell提供空资源模块,则可以解决此问题。
我的画廊形象
x1c 0d1x的数据

我的地形配置:

data "azurerm_resource_group" "example" {
              name = "v-bolliv-Mindtree"
            }
        resource "azurerm_virtual_network" "main" {
              name                = "vkgallery"
              address_space       = ["10.0.0.0/16"]
              location            = data.azurerm_resource_group.example.location
              resource_group_name = data.azurerm_resource_group.example.name
            }
        resource "azurerm_subnet" "internal" {
              name                 = "galleryintvk"
              resource_group_name  = data.azurerm_resource_group.example.name
              virtual_network_name = azurerm_virtual_network.main.name
              address_prefixes     = ["10.0.2.0/24"]
            }
        resource "azurerm_network_interface" "main" {
              name                = "vmgalleryvk"
              location            = data.azurerm_resource_group.example.location
              resource_group_name = data.azurerm_resource_group.example.name
            
              ip_configuration {
                name                          = "testconfvksb"
                subnet_id                     = azurerm_subnet.internal.id
                private_ip_address_allocation = "Dynamic"
              }
            }
        resource "azurerm_virtual_machine" "testingvm" {
              name                        = "galimagevksb"
              resource_group_name         = data.azurerm_resource_group.example.name
              location                    = data.azurerm_resource_group.example.location
              vm_size                     = "Standard_DS1_v2"
              network_interface_ids       = [azurerm_network_interface.main.id]
            
              storage_image_reference {
                id = "/subscriptions/b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f/resourceGroups/v-bolliv-Mindtree/providers/Microsoft.Compute/galleries/demoimagegalleryvk/images/demovkimage"  
                }
             storage_os_disk {
                name                      = "galleryimage-os1"
                caching                   = "ReadWrite"
                create_option             = "FromImage"
                managed_disk_type         = "Standard_LRS"
              }
               os_profile_windows_config {
            enable_automatic_upgrades = false
          }
        }
       }
     
    resource "null_resource" "resourcecli" {
      provisioner "local-exec" {
        command = <<EOT
         command = $vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmName;$vm.OSProfile.SecurityType = "TrustedLaunch";Update-AzVM -ResourceGroupName $resourceGroupName -VM $vm
 }
    EOT
   interpreter = ["PowerShell", "-Command"]
   }
 }

字符串

输出:



0s7z1bwu

0s7z1bwu2#

使用新的资源类型

"azurerm_windows_virtual_machine"
"azurerm_linux_virtual_machine"

字符串
而不是原来的那个

"azurerm_virtual_machine"


使用Terraform配置Win/Linux VM,以便通过使用secure_ Boot _enabled和/或vtpm_enabled属性来利用可信启动等新功能。
更多详细信息:https://registry.terraform.io/providers/hashicorp/azurerm/3.77.0/docs/resources/windows_virtual_machine.html#secure_boot_enabled

相关问题