---
title: "infoblox_ip_allocation"
canonical: "https://docs.infoblox.com/space/ipamdriverterraform/53121460/infoblox_ip_allocation"
format: markdown
---
<span style="color: #000000">The </span>`infoblox_ip_allocation`<span style="color: #000000"> 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, dynamically as the next available IP address from the specified IPv4 and/or IPv6 network blocks or by specifying the extensible attribute filters of parent network.</span>

<span style="color: #000000">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.</span>

<span style="color: #000000">The following table describes the parameters you can define in the </span>`infoblox_ip_allocation`<span style="color: #000000"> resource block:</span>

| <span style="color: #000000">**Parameter**</span> | <span style="color: #000000">**Required/**</span>  
<span style="color: #000000">**Optional**</span> | <span style="color: #000000">**Description**</span> | <span style="color: #000000">**Example Value**</span> |
| --- | --- | --- | --- |
| `fqdn` | <span style="color: #000000">Required</span> | <span style="color: #000000">Specifies the name (in FQDN format) of a host with which an IP address needs to be allocated.</span>  
<span style="color: #000000">In a cloud environment, a VM name could be used as a host name.</span>  
If you disable the flag for a host record with its name in the FQDN format and the `enable_dns` flag enabled, you must remove the zone part from the record name and keep only the host name. For example, you must change `hostname1.zone.com` to `hostname1`. | <span style="color: #000000"> </span>`ip-12-34-56-78.us-west-2.compute.internal` |
| `network_view` | <span style="color: #000000">Optional</span> | <span style="color: #000000">Specifies the network view from which to get the specified network block.</span>  
If a value is not specified, the name `default` is set as the network view. | `dmz_netview` |
| `dns_view` | <span style="color: #000000">Optional</span> | <span style="color: #000000">Specifies the DNS view in which to create the DNS resource records that are associated with the IP address.</span><br>- If `enable_dns` is set to `true`, you must configure this parameter.
- If `enable_dns` is set to `false`, you must remove this parameter from the resource block.<br>For more information, see the description of the `enable_dns` parameter. | `dmz_dnsview` |
| `enable_dns` | <span style="color: #000000">Optional</span> | <span style="color: #000000">A flag that specifies whether DNS records associated with the resource must be created.</span>  
<span style="color: #000000">The default value is </span>`true`<span style="color: #000000">.</span><br>When you update the enable_dns parameter, consider the following points:<br>- If you set the parameter to `false` when creating a resource, you must not specify the `dns_view` parameter.
- If you set the parameter to `false` when updating a resource, you must:
  - Remove the `dns_view` parameter. Not removing it can result in unexpected errors.
  - Remove the zone part in the FQDN, and keep only the host record’s name.  
For example, an FQDN with `host1` as the record name and `example.org` as the zone must be changed from `host1.example.org`<span style="color: #ff5630"> </span>to<span style="color: #ff5630"> </span>`host1`.
- If you set the parameter from `false` to `true`, you must:
  - Specify the `dns_view` parameter. If you do not, the name `default` will not be configured.
  - Change the `fqdn` value to FQDN without a leading dot. That is, to the name of the host record, add a zone that exists in the specified DNS view.  
For example, if the `fqdn` value is `host1` and the zone selected from the specified DNS view is `example.com`, then the `fqdn` must be changed to `host1.example.com`. | `true` |
| `ipv4_cidr` | <span style="color: #000000">Required only for dynamic allocation</span> | <span style="color: #000000">Specifies the IPv4 network block (in CIDR format) from where to allocate an IP address.</span>  
<span style="color: #000000">Use this parameter only when ipv4_addr is not specified.</span> | `10.0.0.0/24` |
| `ipv6_cidr` | <span style="color: #000000">Required only for dynamic allocation</span> | <span style="color: #000000">Specifies the IPv6 network block (in CIDR format) from where to allocate an IP address.</span>  
<span style="color: #000000">Use this parameter only when </span>`ipv6_addr`<span style="color: #000000"> is not specified.</span> | `2000:1148::/32`<span style="color: #000000"> </span> |
| `ipv4_addr` | <span style="color: #000000">Required only for static allocation</span> | <span style="color: #000000">Specifies an IPv4 address to allocate.</span>  
<span style="color: #000000">Use this parameter only when </span>`ipv4_cidr`<span style="color: #000000"> is not specified.</span>  
<span style="color: #000000">The allocated IP address will be marked as ‘Used’ in NIOS Grid Manager.</span>  
The default value is an empty string. If you specify both `ipv4_addr` and `ipv4_cidr`, then `ipv4_addr` takes precedence. | `10.0.0.10` |
| `ipv6_addr` | <span style="color: #000000">Required only for static allocation</span> | <span style="color: #000000">Specifies an IPv6 address to allocate.</span>  
<span style="color: #000000">Use this parameter only when </span>`ipv6_cidr`<span style="color: #000000"> is not specified.</span>  
<span style="color: #000000">The allocated IP address will be marked as ‘Used’ in NIOS Grid Manager.</span>  
The default value is an empty string. If you specify both `ipv6_addr` and `ipv6_cidr`, then `ipv6_addr` takes precedence. | `2000:1148::10` |
| `filter_params` | Optional | Specifies the extensible attributes of the parent network that must be used as filters to retrieve the next available IP address for creating the host record object. | `jsonencode({`  
` "*Site": "Turkey"`  
` })` |
| `ip_address_type` | Optional | Specifies the type of IP address to allocate. The valid values are, `IPV4`, `IPV6`, and `Both`. The default value is `IPv4`.  
Note that this field is applicable only when `filter_params` is configured. | `Both` |
| `disable` | Optional | Disables the record if set to `true`. The default value is `false`. | `false` |
| `aliases` | Optional | Specifies a list of aliases for the host record. | `["aws880.test.com"]` |
| `ttl` | <span style="color: #000000">Optional</span> | <span style="color: #000000">Specifies the time to live value for the DNS record.</span>  
<span style="color: #000000">This parameter is relevant only when </span>`enable_dns`<span style="color: #000000"> is set to </span>`true`<span style="color: #000000">.</span>  
<span style="color: #000000">If a value is not specified</span>, then in NIOS, the value is inherited<span style="color: #000000"> from the parent object of the DNS record for this resource.</span> | `3600` |
| `comment` | <span style="color: #000000">Optional</span> | Specifies the human readable description of the resource. | `Front-end cloud node.` |
| `ext_attrs` | <span style="color: #000000">Optional</span> | <span style="color: #000000">Specifies the set of NIOS extensible attributes that are attached to the NIOS resource.</span><br><span style="color: #000000">An extensible attribute must be a JSON map translated into a string value.</span> | `ext_attrs = jsonencode({ "Tenant ID" = "tf-plugin"`  
` "Location" = "Test loc."`  
` "Site" = "Test site"`  
`})` |

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"`  
`  })`  
`}`

<span style="color: #000000">When you perform a create or an update operation using this allocation resource, the following read-only parameters are computed:</span>

| <span style="color: #000000">**Parameter**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| `allocated_ipv4_addr` | <span style="color: #000000">If you allocated a dynamic IP address, this value is the IP address allocated from the specified IPv4 CIDR.</span>  
<span style="color: #000000">If you allocated a static IP address, this value is the IP address that you specified in the </span>`ipv4_addr`<span style="color: #000000"> field.</span>  
<span style="color: #000000">You can reference this field for the IP address when using other resources.</span>  
<span style="color: #000000">Example:</span><br>`resource "infoblox_ip_aloocation" "allocation1" {`  
`  ipv4_cidr = infoblox_ipv4_network.cidr`  
`  fqdn = local.vm_name`  
`}`<br><span style="color: #000000">You can add a reference for the IP address as follows:</span><br>`infoblox_ip_allocation.allocation1.allocated_ipv4_addr` |
| `allocated_ipv6_addr` | <span style="color: #000000">If you allocated a dynamic IP address, this value is the IP address allocated from the specified IPv6 CIDR.</span>  
<span style="color: #000000">If you allocated a static IP address, this value is the IP address that you specified </span>`ipv6_addr`<span style="color: #000000"> field.</span><br><span style="color: #000000">You can reference this field for the IP address when using other resources. See the previous description for an example.</span> |

## <span style="color: #000000">Example of the Resource Block</span>

You can use static and dynamic allocation methods independently to assign IPv4 and IPv6 addresses within the same resource.

`// minimal set of parameters for IP address allocation`  
`resource "infoblox_ip_allocation" "allocation1" {`  
`    dns_view = "default" // this time the parameter is not optional, because...`  
`    # enable_dns = true // ... this is 'true', by default`  
`    fqdn = "example1.org " // this resource type is implemented as a host record at the NIOS side`  
`    ipv4_addr = "1.2.3.4"`  
`}`  


`// Wide set of parameters`  
`resource "infoblox_ip_allocation" "allocation2" {`  
`    dns_view = "nondefault_dnsview1"`  
`    fqdn = "example2.org "`  
`    ipv6_addr = "2002:1f93::1234"`  
`    ttl = 120`  
`    comment = "another host record, statically allocated"`  
`    ext_attrs = jsonencode({`  
`         "Tenant ID" = "tenant_3261798"`  
`    })`  
`}`  


`// allocation of IPv4 and IPv6 address simultaneously`  
`resource "infoblox_ip_allocation" "allocation3" {`  
`    dns_view = "nondefault_dnsview2"`  
`    network_view = "nondefault_netview" // you must specify the network view`  
`    // which the DNS view belongs to`  
`    fqdn = "host3.example4.org"`  
`    ipv6_addr = "2002:1f93::12:40"`  
`    ipv4_addr = "1.2.3.40"`  
`    ttl = 0`  
`    comment = "still statically allocated, but IPv4 and IPv6 together"`  
`    ext_attrs = jsonencode({`  
`       "Tenant ID" = "tenant_3261798"`  
`    })`  
`}`  


`resource "infoblox_ip_allocation" "allocation4" {`  
`      enable_dns = false`  
`      # dns_view = "nondefault_dnsview2" // remove or comment out dns_view`  
`      // when enable_dns = false`  
`      network_view = "nondefault_netview" // you must mention the network view which the`  
`       //DNS view belongs to`  
`      fqdn = "host4" // just one name component because there is no host-to-DNS-zone assignment`  
  
`      // either of the IP addresses must belong to an existing network`  
`      // (not a network container) in the specified network view`  
`      // because of enable_dns = false`  
`      ipv6_addr = "2002:1f93::12:40"`  
`      ipv4_addr = "10.1.0.60"`  
  
`      // ensure that the appropriate network exists before creating this resource`  
`      depends_on = [infoblox_ipv4_network.net1]`  
`}`  


`// dynamic allocation`  
`resource "infoblox_ip_allocation" "allocation5" {`  
`    dns_view = "nondefault_dnsview2"`  
`    network_view = "nondefault_netview"`  
`    fqdn = "host5.example4.org"`  
`    ipv6_cidr = infoblox_ipv6_network.net2.cidr`  
`    ipv4_cidr = infoblox_ipv4_network.net2.cidr`  
`}`  


`//Host record resource using next-available-IP address based on extensible attributes tag`   
`resource "infoblox_ip_allocation" "rec_host17" {`  
`    fqdn = "new777.test.com"`  
`    aliases = ["www.test.com"] `  
`    disable = false `  
`//Extensible attributes of parent network `  
`    filter_params = jsonencode({`  
`      "*Site": "Turkey"`  
`    })`  
`    ip_address_type = "Both"`  
`    enable_dns = true`  
`    ttl = 60`  
`}`