Skip to content

Commit

Permalink
Implement terraform drift management by Terraform Internal ID EA
Browse files Browse the repository at this point in the history
* Added support for Terraform Internal ID EA to RecordA. (#327)

Modified povider.go

* Added new EA Terraform IntrenalID with UUID to identify the resource as unique ID as ref changes on value change

* Updated A, CNAME, MX, Network, NetworkContainer and NetworkView with Internal ID support.

* Clean state file for Host record during Refresh if resource not exist.

* Feature/resource id management (#333)

* Added support for Terraform Internal ID EA to AAAA, PTR, SRV, TXT.

* Added support for Terraform Internal ID EA to dns view and zone auth.

* [FIX] Handle ext_attrs from panic when Null, Network view ext_attrs idempotent for each apply. (#335)

[IMP] Remove "Terraform Internal ID" from the ext_attrs from state file.

* Fixed Host record import when recored created without mac or uuid. (#334)

* [IMP] Updated Go-client with latest commit and updated vendor dir. (#336)

* [FIX] IP Allocation crash on next terraform apply when MAC address is nil. (#337)

* [FIX] NIOS-99926 | Handle EA for NULL (#338)

* - [Fix] Nios-100049 | Updated ipv6 network examples (#340)

* [Fix] NIOS-100160 | Corrected datasource examples (#341)

* [Fix] Nios-100160 | Corrected datasource examples

* [Fix] Nios-100160 | Corrected datasource examples

* Feature/resource id management (#339)

* Added support for Terraform Internal ID EA to AAAA, PTR, SRV, TXT.

* Added support for Terraform Internal ID EA to dns view and zone auth.

* - Added Prerequisites for TF_ACC test cases.
- Added Dependencies to test files.
- Updated record search with new field internal ID

* Updated vendor directory with Go-client V2.6.0

---------

Co-authored-by: Jeenitkumar Khatri <58591067+JkhatriInfobox@users.noreply.github.com>
  • Loading branch information
JchhatbarInfoblox and JkhatriInfobox authored Apr 8, 2024
1 parent 7eef978 commit 17ebe33
Show file tree
Hide file tree
Showing 68 changed files with 3,654 additions and 880 deletions.
4 changes: 2 additions & 2 deletions docs/data-sources/infoblox_ipv4_network_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ all network containers will be fetched in results.

```hcl
resource "infoblox_ipv4_network_container" "nearby_org" {
cidr = "192.168.128.0/16"
cidr = "192.168.128.0/17"
network_view = "separate_tenants"
comment = "one of our clients"
ext_attrs = jsonencode({
Expand All @@ -56,7 +56,7 @@ resource "infoblox_ipv4_network_container" "nearby_org" {
data "infoblox_ipv4_network_container" "nearby_nc" {
filters = {
network_view = "separate_tenants"
cidr = "192.168.128.0/16"
network = "192.168.128.0/17"
}
// This is just to ensure that the network container has been be created
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/infoblox_mx_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ resource "infoblox_mx_record" "rec2" {
data "infoblox_mx_record" "ds2" {
filters = {
dns_view = "nondefault_dnsview1"
fqdn = "rec2.example2.org"
view = "nondefault_dnsview1"
name = "rec2.example2.org"
mail_exchanger = "sample.test.com"
}
Expand Down
26 changes: 13 additions & 13 deletions docs/data-sources/infoblox_ptr_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ From the below list of supported arguments for filters, use only the searchable
### Supported Arguments for filters

-----
| Field | Alias | Type | Searchable |
|-------------|----------|--------|------------|
| ptrdname | ptrdname | string | yes |
| record_name | name | string | yes |
| view | dns_view | string | yes |
| ipv4addr | ip_addr | string | yes |
| ipv6addr | ip_addr | string | yes |
| ttl | ttl | uint32 | no |
| comment | comment | string | yes |
| zone | zone | string | yes |
| Field | Alias | Type | Searchable |
|----------|--------------|--------|------------|
| ptrdname | ptrdname | string | yes |
| name | record_name | string | yes |
| view | dns_view | string | yes |
| ipv4addr | ip_addr | string | yes |
| ipv6addr | ip_addr | string | yes |
| ttl | ttl | uint32 | no |
| comment | comment | string | yes |
| zone | zone | string | yes |

!> From above list, both ipv4addr and ipv6addr are not allowed together in filters. Apart from this any other combination is allowed.

Expand Down Expand Up @@ -70,7 +70,7 @@ resource "infoblox_ptr_record" "host1" {
data "infoblox_ptr_record" "host1" {
filters = {
ptrdname="host.example.org"
ip_addr="2a05:d014:275:cb00:ec0d:12e2:df27:aa60"
ipv6addr="2a05:d014:275:cb00:ec0d:12e2:df27:aa60"
}
// This is just to ensure that the record has been be created
Expand All @@ -84,9 +84,9 @@ output "ptr_rec_res" {
data "infoblox_ptr_record" "host2" {
filters = {
dns_view="default"
view="default"
ptrdname="host.example.org"
record_name="0.6.a.a.7.2.f.d.2.e.2.1.d.0.c.e.0.0.b.c.5.7.2.0.4.1.0.d.5.0.a.2.ip6.arpa"
name="0.6.a.a.7.2.f.d.2.e.2.1.d.0.c.e.0.0.b.c.5.7.2.0.4.1.0.d.5.0.a.2.ip6.arpa"
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/infoblox_srv_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ resource "infoblox_srv_record" "rec2" {
data "infoblox_srv_record" "ds1" {
filters = {
dns_view = "nondefault_dnsview1"
view = "nondefault_dnsview1"
name = "_sip._udp.example2.org"
port = 5060
target = "sip.example2.org"
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/infoblox_txt_record.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "infoblox_txt_record" "rec3" {
data "infoblox_txt_record" "ds3" {
filters = {
dns_view = "nondefault_dnsview1"
view = "nondefault_dnsview1"
name = "example3.example2.org"
}
Expand All @@ -89,6 +89,6 @@ data "infoblox_txt_record" "txt_rec_ea" {
// throws matching TXT-Records with EA, if any
output "txt_rec_out" {
value = data.infoblox_infoblox_record.txt_rec_ea
value = data.infoblox_txt_record.txt_rec_ea
}
```
4 changes: 2 additions & 2 deletions docs/resources/infoblox_ipv6_network.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "infoblox_ipv6_network" "net1" {
resource "infoblox_ipv6_network" "net2" {
cidr = "2002:1f93:0:4::/96"
network_view = "nondefault_netview"
reserve_ip = 10
reserve_ipv6 = 10
gateway = "2002:1f93:0:4::1"
comment = "let's try IPv6"
ext_attrs = jsonencode({
Expand All @@ -43,7 +43,7 @@ resource "infoblox_ipv6_network" "net3" {
parent_cidr = infoblox_ipv6_network_container.v6net_c1.cidr // reference to the resource from another example
allocate_prefix_len = 100 // 96 (existing network container) + 4 (new network), prefix
network_view = "default" // we may omit this but it is not a mistake to specify explicitly
reserve_ip = 20
reserve_ipv6 = 20
gateway = "none" // no gateway defined for this network
comment = "the network for the Test Lab"
ext_attrs = jsonencode({
Expand Down
4 changes: 2 additions & 2 deletions examples/datasources/infoblox_mx_record.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ resource "infoblox_mx_record" "rec2" {

data "infoblox_mx_record" "ds2" {
filters = {
dns_view = "nondefault_dnsview1"
fqdn = "rec2.example2.org"
view = "nondefault_dnsview1"
name = "rec2.example2.org"
mail_exchanger = "sample.test.com"
}

Expand Down
2 changes: 1 addition & 1 deletion examples/datasources/infoblox_ptr_record.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "infoblox_ptr_record" "host1" {
data "infoblox_ptr_record" "host1" {
filters = {
ptrdname="host.example.org"
ip_addr="2a05:d014:275:cb00:ec0d:12e2:df27:aa60"
ipv6addr="2a05:d014:275:cb00:ec0d:12e2:df27:aa60"
}

// This is just to ensure that the record has been be created
Expand Down
2 changes: 1 addition & 1 deletion examples/datasources/infoblox_srv_record.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resource "infoblox_srv_record" "rec2" {

data "infoblox_srv_record" "ds1" {
filters = {
dns_view = "nondefault_dnsview1"
view = "nondefault_dnsview1"
name = "_sip._udp.example2.org"
port = 5060
target = "sip.example2.org"
Expand Down
2 changes: 1 addition & 1 deletion examples/datasources/infoblox_txt_record.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "infoblox_txt_record" "rec3" {

data "infoblox_txt_record" "ds3" {
filters = {
dns_view = "nondefault_dnsview1"
view = "nondefault_dnsview1"
name = "example3.example2.org"
}

Expand Down
4 changes: 2 additions & 2 deletions examples/resources/infoblox_ipv6_network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "infoblox_ipv6_network" "net1" {
resource "infoblox_ipv6_network" "net2" {
cidr = "2002:1f93:0:4::/96"
network_view = "nondefault_netview"
reserve_ip = 10
reserve_ipv6 = 10
gateway = "2002:1f93:0:4::1"
comment = "let's try IPv6"
ext_attrs = jsonencode({
Expand All @@ -20,7 +20,7 @@ resource "infoblox_ipv6_network" "net3" {
parent_cidr = infoblox_ipv6_network_container.nc1.cidr // reference to the resource from another example
allocate_prefix_len = 100 // 96 (existing network container) + 4 (new network), prefix
network_view = "default" // we may omit this but it is not a mistake to specify explicitly
reserve_ip = 20
reserve_ipv6 = 20
gateway = "none" // no gateway defined for this network
comment = "the network for the Test Lab"
ext_attrs = jsonencode({
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0
github.com/infobloxopen/infoblox-go-client/v2 v2.4.0
github.com/infobloxopen/infoblox-go-client/v2 v2.6.0
github.com/sirupsen/logrus v1.8.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/infobloxopen/infoblox-go-client/v2 v2.4.0 h1:B8/Ej06SbhN44F2eQq18k6eWgY2XaZocCIloZyKD1Hk=
github.com/infobloxopen/infoblox-go-client/v2 v2.4.0/go.mod h1:Zu7c+X0mTB6ahIYm7p9LlvfcH814ZUEP+eXGPEYLDU4=
github.com/infobloxopen/infoblox-go-client/v2 v2.6.0 h1:nwdGhQ5XRheGybEdUQ4cSl1Vw2UsSQKKi+HEleguQug=
github.com/infobloxopen/infoblox-go-client/v2 v2.6.0/go.mod h1:Zu7c+X0mTB6ahIYm7p9LlvfcH814ZUEP+eXGPEYLDU4=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
Expand Down
11 changes: 10 additions & 1 deletion infoblox/datasource_infoblox_a_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ func TestAccDataSourceARecord(t *testing.T) {
}

var testAccDataSourceARecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_a_record" "foo"{
dns_view="default"
fqdn="test-name.test.com"
ip_addr="10.0.0.20"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_a_record" "acctest" {
Expand All @@ -48,6 +53,9 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_a_record" "arec1"{
ip_addr = "10.4.0.18"
fqdn = "sample.test.com"
Expand All @@ -56,6 +64,7 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Location": "Las Vegas"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_a_record" "ds1" {
Expand All @@ -70,7 +79,7 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.ip_addr", "10.4.0.18"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.fqdn", "sample.test.com"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.comment", "test sample A-record"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.ext_attrs", "{\"Location\":\"Las Vegas\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_a_record.ds1", "results.0.ext_attrs.Location", "infoblox_a_record.arec1", "ext_attrs.Location"),
),
},
},
Expand Down
10 changes: 9 additions & 1 deletion infoblox/datasource_infoblox_aaaa_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ func TestAccDataSourceAAAARecord(t *testing.T) {
}

var testAccDataSourceAAAARecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_aaaa_record" "foo"{
dns_view="default"
fqdn="aaaa-test.test.com"
ipv6_addr="2002:1111::7"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_aaaa_record" "acctest" {
Expand All @@ -48,6 +52,9 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_aaaa_record" "qarec1"{
ipv6_addr = "2002:1f93:0:4::11"
fqdn = "sampleqa.test.com"
Expand All @@ -56,6 +63,7 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Location": "Norway"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_aaaa_record" "dqa1" {
Expand All @@ -71,7 +79,7 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.ipv6_addr", "2002:1f93:0:4::11"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.fqdn", "sampleqa.test.com"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.comment", "test sample AAAA-record"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.ext_attrs", "{\"Location\":\"Norway\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_aaaa_record.dqa1", "results.0.ext_attrs.Location", "infoblox_aaaa_record.qarec1", "ext_attrs.Location"),
),
},
},
Expand Down
12 changes: 10 additions & 2 deletions infoblox/datasource_infoblox_cname_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ func TestAccDataSourceCNameRecord(t *testing.T) {
}

var testAccDataSourceCNameRecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_cname_record" "foo"{
dns_view="default"
alias="test.test.com"
canonical="test-name.test.com"
canonical="test-name.test.com"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_cname_record" "acctest" {
Expand All @@ -49,6 +53,9 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_cname_record" "cname1"{
canonical = "somewhere.in.the.net"
alias = "samplecname.test.com"
Expand All @@ -57,6 +64,7 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Site": "test site one"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_cname_record" "dcname1" {
Expand All @@ -71,7 +79,7 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.canonical", "somewhere.in.the.net"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.alias", "samplecname.test.com"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.comment", "test sample CName-record"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.ext_attrs", "{\"Site\":\"test site one\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_cname_record.dcname1", "results.0.ext_attrs.Site", "infoblox_cname_record.cname1", "ext_attrs.Site"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion infoblox/datasource_infoblox_dns_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestAccDataSourceDNSViewSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.name", "customview"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.network_view", "default"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.comment", "new dns view example"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.ext_attrs", "{\"Site\":\"Main DNS Site\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_dns_view.accview", "results.0.ext_attrs.Site", "infoblox_dns_view.dview1", "ext_attrs.Site"),
),
},
},
Expand Down
Loading

0 comments on commit 17ebe33

Please sign in to comment.