Add option to define name in allocation
Closed this issue · 2 comments
robertbrandso commented
It would be great if it was possible to add a name of some kind for the allocation in the json file, to easier present the content of the json file in some kind of documentation or something.
Suggested configuration
resource "ipam_pool" "main" {
cidr = "10.0.0.0/8"
}
resource "ipam_allocation" "foo" {
name = "foo"
pool_id = ipam_pool.main.id
size = 24
}
agrrh commented
This provider heavily relies on metal-stack/go-ipam, which does not support prefixes naming at the moment.
We at metal-stack store these information alongside the gathered IP/Prefix.
Would it suit your needs to present data with tf state show
?
# ipam_allocation.customer_a:
resource "ipam_allocation" "customer_a" {
cidr = "10.2.0.0/16"
id = "10.2.0.0/16"
pool_id = "10.0.0.0/8"
size = 16
}
robertbrandso commented
Understand. Thank you anyway!
I may do something like this to solve what I'm after:
# Create IPAM allocations
locals {
apps = toset([
"app1",
"app2",
"app3"
])
}
resource "ipam_allocation" "apps" {
for_each = local.apps
pool_id = ipam_pool.main.id
size = 24
}
# Output IPAM allocation with application name as key and IP allocation as value
output "apps_ip_allocation" {
description = "Shows every IP allocation done for apps."
value = { for k,v in ipam_allocation.apps : k => v.cidr }
}
To get a JSON file, we can for example doterraform output -json | jq '.apps_ip_allocation.value' > ipam_allocations.json
.