-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: random IP from CIDR range #517
Comments
What are your thoughts on this @bendbennett? |
Hey there @bschaatsbergen 👋, thanks for raising this issue! Just wanted to quickly point out, since the The feature requested here is an expansion of what the
If this is the main drive behind this new resource, that might make a good candidate to live in a new provider that focuses on generating realistic mock test data, a Terraform sibling of something like faker-js. The recent addition of test mocking in Terraform 1.7 might make providers that produce realistic fake data like that more desirable. I see a couple others have upvoted this issue in particular, so if there are any use-cases for random IPs that are not mocking/test data specific, we would be interested to hear about those as well. |
Hey @austinvalle, appreciate the detailed feedback on the requested feature. I understand the importance of prioritizing stability over additional features, and I agree that we should carefully consider which resources to incorporate into this provider. Has a realistic mock data Terraform Provider been discussed before? If the DevEx team is keen on having this, I would love to kick start this - generating realistic mock data such as dates, IPs, and email addresses. What's your take on this? |
I'm not 100% sure, although my team isn't as involved with the Terraform module testing functionality recently released. I'd imagine folks closer to that community would have a better idea on how useful a provider would really be there. (vs. just hardcoding test data)
The providers our team supports are more focused on RFC-backed functionality (like |
I’d like to chime in with another potential use case for the One common scenario involves deploying EC2 instances where we need to ensure a stable public IP (or, in the case of IPv6, a stable address) across instance replacements or redeployments. For example, with IPv4 EIP (Elastic IP), we can assign a static public IP to an instance that remains consistent even during instance recreation. However, when working with IPv6, there isn’t always a direct equivalent of an EIP for IPv6. I’m thinking the random_ip resource could be used as a stable IPv6 address source, avoiding the need to manually hardcode one while still ensuring that the IP doesn't change across instance recreations. Here’s how it could look in practice: resource "aws_instance" "main" {
ipv6_addresses = [random_ip.main.address]
}
resource "random_ip" "main" {
cidr_range = aws_subnet.public.ipv6_cidr_block
}
resource "aws_route53_record" "main" {
zone_id = "..."
name = "www"
type = "AAAA"
ttl = 300
records = [random_ip.main.address]
} This would allow for a dynamic yet stable IPv6 setup, which could be particularly useful in VPC use cases where you’re deploying many instances but want predictable IP addressing without needing to hardcode specific IPv6 addresses upfront. Thanks for considering this perspective! |
Thanks for the use-case @ciffelia 👋🏻 For any future travelers of this feature request, the current status of this issue is the maintainers would like to see more use-cases for how this Some additional things to consider including (@ciffelia has a great example as well, providing a use-case):
|
I used it for This would make it 100 times more smooth. |
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:
terraform test
framework, performing egress network connectivity tests against a set of generated IP addresses in a range I'm actively denying or allowing.Example usage
Basic:
IPv4:
IPv6:
Using a count:
Using a count followed by a distinct:
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. :)
The text was updated successfully, but these errors were encountered: