Azure provioning的terraform模板出错

时间:2017-04-13 08:31:33

标签: azure terraform

我正在尝试使用terraform(版本0.9.3)azurerm配置文件创建虚拟机,但是获得通用错误 不是有效的计划文件 。 这种情况发生在 应用 计划 选项中。

我尝试使用terraform版本0.8.2并将错误消息更改为 加载配置时出错:配置路径必须是目录:

我不确定这里有什么问题。下面是我正在执行的模板。 感谢任何帮助。

provider "azurerm" {
    subscription_id = "${var.my_subscription_id}"
    client_id       = "${var.my_client_id}"
    client_secret   = "${var.my_client_secret}"
    tenant_id       = "${var.my_tenant_id}"
}


resource "azurerm_resource_group" "terraform_rg" {
    name     = "terraform_rg"
    location = "West US"
    tags {
        name = "terraformpoc"
  }
}

resource "azurerm_network_security_group" "terraform_sg" {
    name                = "terraformSG1"
    location            = "West US"
    resource_group_name = "${azurerm_resource_group.terraform_rg.name}"
    security_rule {
        name                       = "SGRule"
        priority                   = 100
        direction                  = "Inbound"
        access                     = "Allow"
        protocol                   = "Tcp"
        source_port_range          = "*"
        destination_port_range     = "*"
        source_address_prefix      = "*"
        destination_address_prefix = "*"
    }
    tags {
        name = "terraformpoc"
    }
}

resource "azurerm_network_interface" "terraform_ni" {
    name                = "terraforminstni"
    location            = "West US"
    resource_group_name = "${azurerm_resource_group.terraform_rg.name}"
    network_security_group_id = "${azurerm_network_security_group.terraform_sg.id}"
    enable_ip_forwarding = true
    ip_configuration {
        name                          = "terraformtestconfig"
        subnet_id                     = "${var.my_subnet}"
        private_ip_address_allocation = "dynamic"
    }
}


resource "azurerm_virtual_machine" "terraform_vm" {
    name                  = "terraforminstvm"
    location              = "West US"
    resource_group_name   = "${azurerm_resource_group.terraform_rg.name}"
    network_interface_ids = ["${azurerm_network_interface.terraform_ni.id}"]
    vm_size               = "Standard_A0"
    delete_data_disks_on_termination  = true
    storage_image_reference {
        publisher = "Canonical"
        offer     = "UbuntuServer"
        sku       = "14.04.2-LTS"
        version   = "latest"
    }

    storage_os_disk {
        name          = "myosdisk1"
        caching       = "ReadWrite"
        create_option = "FromImage"
    }   

    os_profile {
        computer_name  = "hostname"
        admin_username = "${var.my_admin_username}"
        admin_password = "${var.my_admin_password}"
    }

    os_profile_linux_config {
        disable_password_authentication = false
    }

    tags {
        name = "terraformpoc"
    }
}

0 个答案:

没有答案