Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform Azure Virtual Machine from Community images #25612

Open
1 task done
motorbreth opened this issue Apr 15, 2024 · 1 comment
Open
1 task done

Terraform Azure Virtual Machine from Community images #25612

motorbreth opened this issue Apr 15, 2024 · 1 comment

Comments

@motorbreth
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.6.5

AzureRM Provider Version

3.98.0

Affected Resource(s)/Data Source(s)

azurerm_linux_virtual_machine

Terraform Configuration Files

resource "azurerm_network_interface" "VM_nic" {
  name                = "VM-nic"
  location            = azurerm_resource_group.servers.location
  resource_group_name = azurerm_resource_group.servers.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.servers_subnet.id
    private_ip_address_allocation = "Dynamic"

resource "azurerm_linux_virtual_machine" "BackBox_vm" {
  name                            = "BackBox"
  computer_name                   = "BackBox"
  location                        = azurerm_resource_group.servers.location
  resource_group_name             = azurerm_resource_group.servers.name
  zone                            = "1"
  network_interface_ids           = [azurerm_network_interface.VM_nic.id]
  size                            = "Standard_D2s_v3"
  source_image_id                 = "/communityGalleries/BackBox-39ccaf4b-e81f-4250-a8f4-e32bc23a8312/images/BackBox"
  admin_username                  = "admin"
  admin_password                  = "Passw0rd"

  disable_password_authentication = false

  os_disk {
    name                 = "os-disk"
    caching              = "ReadWrite"
    storage_account_type = "Premium_LRS"
    disk_size_gb         = 128
  }
}

Debug Output/Panic Output

this image dosnt need a user and password set , when creating the vm in azure portal its not asking for a user and password , when running terraform it fails with missing user name or password

but when i set 
admin_username                  = "admin"
admin_password                  = "Passw0rd"
disable_password_authentication = false
it fails with 

Virtual Machine Name: "BackBox"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Parameter 'osProfile' is not allowed." Target="osProfile"

Expected Behaviour

create a vm from comunity image and add username and password later in the install process of the vm

Actual Behaviour

terraform plan works
terraform apply fails with
Virtual Machine Name: "BackBox"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Parameter 'osProfile' is not allowed." Target="osProfile"

Steps to Reproduce

resource "azurerm_network_interface" "VM_nic" {
  name                = "VM-nic"
  location            = azurerm_resource_group.servers.location
  resource_group_name = azurerm_resource_group.servers.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.servers_subnet.id
    private_ip_address_allocation = "Dynamic"

resource "azurerm_linux_virtual_machine" "BackBox_vm" {
  name                            = "BackBox"
  computer_name                   = "BackBox"
  location                        = azurerm_resource_group.servers.location
  resource_group_name             = azurerm_resource_group.servers.name
  zone                            = "1"
  network_interface_ids           = [azurerm_network_interface.VM_nic.id]
  size                            = "Standard_D2s_v3"
  source_image_id                 = "/communityGalleries/BackBox-39ccaf4b-e81f-4250-a8f4-e32bc23a8312/images/BackBox"
  admin_username                  = "admin"
  admin_password                  = "Passw0rd"

  disable_password_authentication = false

  os_disk {
    name                 = "os-disk"
    caching              = "ReadWrite"
    storage_account_type = "Premium_LRS"
    disk_size_gb         = 128
  }
}

terraform apply

Important Factoids

No response

References

No response

@ghost

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants