-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Labels
enhancementneeds-more-inputIssues or PRs that need more real-world use-cases before acceptingIssues or PRs that need more real-world use-cases before acceptingnew-resource
Description
It would be nice to have a resource that generates random IPv4 or IPv6 addresses within a specified CIDR range.
Why:
I'm sure this can serve various purposes, as people are more creative than I am.
Use cases I can think of:
- Helpful to combine with the
terraform testframework, performing egress network connectivity tests against a set of generated IP addresses in a range I'm actively denying or allowing.
Example usage
Basic:
resource "random_ip" "example" {}
IPv4:
resource "random_ip" "example" {
cidr_range = "192.168.0.0/24"
}
IPv6:
resource "random_ip" "example" {
cidr_range = "2001:db8::/32"
}
Using a count:
resource "random_ip" "example" {
count = 5
cidr_range = "2001:db8::/32"
}
output "random_ipv6_addresses" {
value = random_ip.example[*].result
}
Using a count followed by a distinct:
resource "random_ip" "example" {
count = 50
cidr_range = "192.168.1.0/28"
}
output "random_distinct_ipv4_addresses" {
value = distinct(random_ip.example[*].result)
}
I'm would love to contribute this new resource if it aligns with the vision of this provider and is something we intend to support. :)
bschaatsbergen, lucioreisgh, mmourick, larahelenaroth, kaspergrubbe and 3 more
Metadata
Metadata
Assignees
Labels
enhancementneeds-more-inputIssues or PRs that need more real-world use-cases before acceptingIssues or PRs that need more real-world use-cases before acceptingnew-resource