Fediversity/deployment/run/tf-netbox-get-ip/main.tf

35 lines
728 B
HCL

terraform {
required_providers {
netbox = {
source = "e-breuninger/netbox"
version = "= 5.0.0"
}
}
backend "http" {
}
}
data "netbox_cluster" "cluster" {
name = var.cluster_name
}
resource "netbox_virtual_machine" "vm" {
cluster_id = data.netbox_cluster.cluster.id
name = var.vm_name
}
resource "netbox_interface" "interface" {
virtual_machine_id = netbox_virtual_machine.vm.id
name = var.interface_name
}
resource "netbox_available_ip_address" "get_ip" {
object_type = "virtualization.vminterface"
interface_id = netbox_interface.interface.id
prefix_id = var.prefix_id
ip_range_id = var.ip_range_id
}
output "ipv4" {
value = netbox_available_ip_address.get_ip.ip_address
}