You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resource random_ip generates a random IP address from a given CIDR range based on the address type specified.
5
+
The random_ip resource generates a random IP address, either IPv4 or IPv6. By default, it randomly chooses between 0.0.0.0/0 (IPv4) and ::/0 (IPv6). You can influence the IP type by specifying a cidr_range.
6
6
---
7
7
8
8
# random_ip (Resource)
9
9
10
-
The resource `random_ip` generates a random IP address from a given CIDR range based on the address type specified.
10
+
The `random_ip`resource generates a random IP address, either IPv4 or IPv6. By default, it randomly chooses between 0.0.0.0/0 (IPv4) and ::/0 (IPv6). You can influence the IP type by specifying a `cidr_range`.
11
11
12
12
## Example Usage
13
13
14
-
### ipv4
14
+
```terraform
15
+
resource "random_ip" "example" {}
16
+
```
17
+
18
+
### IPv4
15
19
16
20
```terraform
17
21
resource "ip" "example" {
18
-
address_type = "ipv4"
19
-
cidr_range = "10.1.0.0/16"
22
+
cidr_range = "10.1.0.0/16"
20
23
}
21
24
```
22
25
23
26
### IPv6
24
27
25
28
```terraform
26
29
resource "ip" "example" {
27
-
address_type = "ipv4"
28
-
cidr_range = "10.1.0.0/16"
30
+
cidr_range = "10.1.0.0/16"
29
31
}
30
32
```
31
33
32
34
### Using a count
33
35
34
-
It could be useful to randomly generate a number of addresses. This can be done using a count.
36
+
It could be useful to randomly generate a number of IP addresses. This can be done using a [count](https://developer.hashicorp.com/terraform/language/meta-arguments/count).
Keep in mind that using a count you could end up with duplicate addresses.
51
-
If you want to avoid this, perform a [distinct](https://developer.hashicorp.com/terraform/language/functions/distinct) on the list of addresses.
51
+
Keep in mind that using a [count](https://developer.hashicorp.com/terraform/language/meta-arguments/count) you could end up with duplicate IP addresses.
52
+
If you want to avoid this, perform a [distinct](https://developer.hashicorp.com/terraform/language/functions/distinct) on the list of IP addresses.
-`address_type` (String) A string indicating the type of IP address to generate. Valid values are `ipv4` and `ipv6`.
71
-
-`cidr_range` (String) A CIDR range from which to allocate the IP address.
72
-
73
68
### Optional
74
69
70
+
-`cidr_range` (String) A CIDR range from which to allocate the IP address.
75
71
-`keepers` (Map of String) Arbitrary map of values that, when changed, will trigger recreation of resource. See [the main provider documentation](../index.html) for more information.
Description: "The resource `random_ip` generates a random IP address from a given CIDR range based on the "+
41
-
"address type specified.",
39
+
Description: "The `random_ip` resource generates a random IP address, either IPv4 or IPv6. By default, it randomly chooses between 0.0.0.0/0 (IPv4) and ::/0 (IPv6). You can influence the IP type by specifying a `cidr_range`.",
42
40
Attributes: map[string]schema.Attribute{
43
41
"keepers": schema.MapAttribute{
44
42
Description: "Arbitrary map of values that, when changed, will trigger recreation of "+
0 commit comments