The infoblox_ip_allocation
resource allows allocation of a new IP address from a network that already exists as a NIOS object. The IP address can be allocated statically by specifying an address or dynamically as the next available IP address from the specified IPv4 and/or IPv6 network blocks.
The allocation is done by creating a Host record in NIOS with an IPv4 address, an IPv6 address, or both assigned to the record. The allocated IP address is marked as ‘used’ in the appropriate network block.
Note
As a prerequisite for creation of Host records using the infoblox_ip_allocation
and infoblox_ip_association
resources, you must create the extensible attribute Terraform Internal ID of string type in Infoblox NIOS Grid Manager. For steps, refer to the Infoblox NIOS Documentation.
The following table describes the parameters you can define in the infoblox_ip_allocation
resource block:
Parameter | Required/ | Description | Example Value |
---|---|---|---|
| Required | Specifies the name (in FQDN format) of a host with which an IP address needs to be allocated. | |
| Optional | Specifies the network view from which to get the specified network block. |
|
| Optional | Specifies the DNS view in which to create the DNS resource records that are associated with the IP address. This parameter is relevant only if |
|
| Optional | A flag that specifies whether DNS records associated with the resource must be created. The default value is |
|
| Required only for dynamic allocation | Specifies the IPv4 network block (in CIDR format) from where to allocate an IP address. Use this parameter only when ipv4_addr is not specified. |
|
| Required only for dynamic allocation | Specifies the IPv6 network block (in CIDR format) from where to allocate an IP address. Use this parameter only when |
|
| Required only for static allocation | Specifies an IPv4 address to allocate. The allocated IP address will be marked as ‘Used’ in NIOS Grid Manager |
|
| Required only for static allocation | Specifies an IPv6 address to allocate. The allocated IP address will be marked as ‘Used’ in NIOS Grid Manager |
|
| Optional | Specifies the time to live value for the DNS record. This parameter is relevant only when |
|
| Optional | Human readable description of the resource. |
|
| Optional | Specifies the set of NIOS extensible attributes that are attached to the NIOS resource. An extensible attribute must be a JSON map translated into a string value. |
|
Note
For a Host record with its name in FQDN format and the enable_dns
flag enabled, if you disable the flag, you must remove the zone part from the record name and only keep the host name.
For example: hostname1.zone.com
must be changed to hostname1
When you use the infoblox_ip_allocation
resource block to allocate or deallocate a static IP address from a Host record, you must configure appropriate dependencies so that workflows run in the correct order. In the following example, dependencies have been configured for network view and the extensible attribute, Network Name:
resource "infoblox_ip_allocation" "ip_allocation" {
network_view = infoblox_ipv6_network.ipv6_network.network_view
ipv4_addr = "10.0.0.32"
ipv6_addr = "2001:1890:1959:2710::32"
#Create Host Record with DNS flags
dns_view="default"
fqdn="testipv4v6"
enable_dns = "false"
ext_attrs = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = lookup(jsondecode(infoblox_ipv4_network.ipv4_network.ext_attrs), "Network Name")
"VM Name" = "tf-vmware-ipv4-ipv61"
"Location" = "Test loc."
"Site" = "Test site"
})
}
When you perform a create or an update operation using this allocation resource, the following read-only parameters are computed:
Parameter | Description |
---|---|
| An ID generated by Terraform for the created resource. Note: As this is a read-only field, you must not configure it as part of a resource block in a .tf file, or edit its value in the Terraform .state file. |
| If you allocated a dynamic IP address, this value is the IP address allocated from the specified IPv4 CIDR. You can reference this field for the IP address when using other resources.
You can add a reference for the IP address as follows:
|
| If you allocated a dynamic IP address, this value is the IP address allocated from the specified IPv6 CIDR. You can reference this field for the IP address when using other resources. See the previous description for an example. |
Example of the Resource Block
You can use static and dynamic allocation methods independently to assign IPv4 and IPv6 addresses within the same resource:
resource "infoblox_ip_allocation" "ipv4v6" {
ipv4_cidr = infoblox_ipv4_network.cidr
ipv6_addr = "2001:1890:1959:2710::32"
#Create Host Record with DNS flags
fqdn="testipv4v6"
enable_dns = "false"
}
resource "infoblox_ip_allocation" "ip_allocation" {
ipv4_addr = "20.0.0.10"
ipv6_addr = "2000::10"
fqdn="testipNew.example.com"
enable_dns = "true"
comment = "tf IPv4 and ipv6 allocation"
ext_attrs = jsonencode({
"Tenant ID" = "tf-plugin"
"Network Name" = "tf-network"
"VM Name" = "tf-ec2-instance"
"Location" = "Test loc2."
"Site" = "Test site"
})
}