---
title: "infoblox_cname_record Data Source"
canonical: "https://docs.infoblox.com/space/ipamdriverterraform/53023399/infoblox_cname_record%20Data%20Source"
format: markdown
---
<span style="color: #000000">Use the data resource for the CNAME object to retrieve the following information for CNAME records:</span>

| **<span style="color: #000000">Parameter</span>** | **<span style="color: #000000">Description</span>** | **<span style="color: #000000">Example</span>** |
| --- | --- | --- |
| `dns_view` | The DNS view in which the record's zone exists. | `nondefault_dnsview` |
| `canonical` | The canonical name of the record in the FQDN format. | `debug.point.somewhere.in` |
| `alias` | <span style="color: #1f2328">The</span><span style="color: #1f2328"> alias name of the record in the FQDN format.</span> | `f``oo1.test.com` |
| `zone` | <span style="color: #000000">The zone that contains the record in the specified DNS view.</span> | `test.com` |
| `ttl` | <span style="color: #000000">The Time to Live value of the record, in seconds.</span> | `3600` |
| `comment` | <span style="color: #000000">A text describing the record. This is a regular comment.</span> | `Temporary A record` |
| `ext_attrs` | <span style="color: #000000">The set of extensible attributes of the record, if any. The content is formatted as a string of JSON map.</span> | `{\"Owner\":\"State Library\",\"Expiry\":\"Never\"}` |

To retrieve information about CNAME records that match the specified filters, use the `filters` argument and specify the parameters mentioned in the below table. These are the searchable parameters of the corresponding object in Infoblox NIOS WAPI. If you do not specify any parameter, the data source retrieves information about all CNAME records in the NIOS Grid.

<span style="color: #000000">The following table describes the parameters you can define in an </span>`infoblox_cname_record`<span style="color: #000000"> data source block:</span>

| **<span style="color: #000000">Parameter</span>** | **<span style="color: #000000">Alias*</span>** | **<span style="color: #000000">Description</span>** |
| --- | --- | --- |
| `name` | `alias` | <span style="color: #000000">Specifies the alias name of the record in the FQDN format.</span> |
| `view` | `dns_view` | <span style="color: #003366">Specifies the DNS view in which the record's zone exists.</span>  
<span style="color: #003366">If a value is not specified, </span><span style="color: #172B4D">matching objects are retrieved from all DNS views in the NIOS Grid.</span> |
| `canonical` | `canonical` | <span style="color: #000000">Specifies the canonical name of the record in the FQDN format.</span> |
| `zone` | `zone` | <span style="color: #000000">Specifies the zone that contains the record.</span> |
| `comment` | `comment` | <span style="color: #000000">Describes the record.</span> |
| <span style="color: #000000">Extensible Attributes</span> | <span style="color: #000000">-</span> | <span style="color: #000000">Specifies the extensible attributes specified for the record. You must specify the</span> key/value pair within the `filters` argument.  
Example:  
`filters = {`  
`"*Site" = "some test site"`  
`"*Location" = "65.8665701230204, -37.00791763398113"`  
`}` |

*<span style="color: #172B4D">Aliases are the parameter names used in the prior releases of Infoblox IPAM Plug-In for Terraform. Do not use the alias names for parameters in the data source blocks. Using them can result in error scenarios</span>.

## <span style="color: #000000">Example of the CNAME Record Data Source Block</span>

<span style="color: #1f2328">This example defines a data source of type </span><span style="color: #000000">`</span><span style="color: #000000">infoblox_cname_record</span><span style="color: #000000">`</span><span style="color: #1f2328"> and the name "cname_rec", which is configured in a Terraform file. </span><span style="color: #000000">You can reference this resource and retrieve information about it.</span>

`resource "infoblox_cname_record" "foo" {`  
`    dns_view = "default.nondefault_netview"`  
`    canonical = "strange-place.somewhere.in.the.net"`  
`    alias = "foo.test.com"`  
`    comment = "we need to keep an eye on this strange host"`  
`    ttl = 0 // disable caching`  
`    ext_attrs = jsonencode({`  
`      Site = "unknown"`  
`      Location = "TBD"`  
`    })`  
  
`}`  
`data "infoblox_cname_record" "cname_rec"{`  
`    filters = {`  
`      name = "foo.test.com"`  
`      canonical = "strange-place.somewhere.in.the.net"`  
`      view = "default.nondefault_netview"`  
`    }`  
  
`    // This is just to ensure that the record has been be created`  
`    // using 'infoblox_cname_record' resource block before the data source will be queried.`  
`    depends_on = [infoblox_cname_record.foo]`  
`}`

`output "``cname_rec_out``" {`  
`    value = data.infoblox_cname_record.cname_rec.results.0.alias //zero represents index of json object from results list`  
`}`

  
`// accessing CNAME-Record through EA's`  
`data "infoblox_cname_record" "cname_rec_ea" {`  
`    filters = {`  
`      "*Location" = "Cali"`  
`      ``"*Location!" = "Florida``"`  
`    }`  
`}`  
`// throws matching CNAME records with EA, if any`  
`output "cname_rec_res" {`  
`    value = data.infoblox_cname_record.cname_rec_ea`  
`}`