mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 10:33:46 +00:00
46 lines
1.2 KiB
HCL
46 lines
1.2 KiB
HCL
resource "proxmox_virtual_environment_vm" "example" {
|
|
cloud_init {
|
|
dns {
|
|
server = "1.1.1.1"
|
|
}
|
|
|
|
ip_config {
|
|
ipv4 {
|
|
address = "dhcp"
|
|
}
|
|
}
|
|
|
|
user_account {
|
|
keys = ["${trimspace(tls_private_key.example.public_key_openssh)}"]
|
|
username = "ubuntu"
|
|
}
|
|
}
|
|
|
|
disk {
|
|
datastore_id = "${element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local-lvm"))}"
|
|
file_id = "${proxmox_virtual_environment_file.ubuntu_cloud_image.id}"
|
|
}
|
|
|
|
network_device {}
|
|
|
|
node_name = "${data.proxmox_virtual_environment_nodes.example.names[0]}"
|
|
os_type = "l26"
|
|
pool_id = "${proxmox_virtual_environment_pool.example.id}"
|
|
vm_id = 2038
|
|
}
|
|
|
|
resource "local_file" "example_ssh_private_key" {
|
|
filename = "${path.module}/autogenerated/id_rsa"
|
|
sensitive_content = "${tls_private_key.example.private_key_pem}"
|
|
}
|
|
|
|
resource "local_file" "example_ssh_public_key" {
|
|
filename = "${path.module}/autogenerated/id_rsa.pub"
|
|
sensitive_content = "${tls_private_key.example.public_key_openssh}"
|
|
}
|
|
|
|
resource "tls_private_key" "example" {
|
|
algorithm = "RSA"
|
|
rsa_bits = 2048
|
|
}
|