Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ There are resources for the following objects, supported by the plugin:
* SRV-record (`infoblox_srv_record`)
* Zone Auth (`infoblox_zone_auth`)
* Host record (`infoblox_ip_allocation` / `infoblox_ip_association`)
* Zone Delegated (`infoblox_zone_delegated`)

Network and network container resources have two versions: IPv4 and IPv6. In
addition, there are two operations which are implemented as resources:
Expand Down
40 changes: 40 additions & 0 deletions docs/resources/infoblox_zone_delegated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Resource Zone Delegated

A Zone Delegated resource creates NS records for a subdomain, pointing to one or more external authoritative name servers. The `infoblox_zone_delegated` resource allow managing such delegations. The parent zone must already exist

The following list describes the parameters you can define in the `infoblox_zone_delegated` resource block:

## Argument Reference
* `fqdn`: (Required) The subdomain name to be delegated
* `delegate_to`: (Required) Nested block(s)s for the delegated name servers
* `name`: (Required) The FQDN of the name server
* `ext_attrs`: (Optional) A set of NIOS extensible attributes that are attached to the record, using jsonencode. Currently only "Tenant ID" is supported

## Attribute Reference
* `delegate_to`:
* `address`: The computed IP address for each delegated name server

## Example Usage

```hcl
resource "infoblox_zone_delegated" "subdomain" {

fqdn = "subdomain.test.com"

delegate_to {
name = "ns-1488.awsdns-58.org"
}

delegate_to {
name = "ns-2034.awsdns-62.co.uk"
}

}
```

## Import
Zone Delegated resources can be imported by using either the object reference or the subdomain fqdn, for example:
```shell script
# terraform import infoblox_zone_delegated.subdomain zone_delegated/ZG5zLnpvbmUkLl9kZWZhdWx0LmNvbS5jb2xsZWdlY2hvaWNldHJhbnNpdGlvbi5nc2xi:subdomain.test.com/default
# terraform import infoblox_zone_delegated.subdomain subdomain.test.com
```
15 changes: 15 additions & 0 deletions examples/v0.14/Resources/ZoneDelegated/infoblox.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Zone Delegated

resource "infoblox_zone_delegated" "subdomain" {

fqdn = "subdomain.example.com"

delegate_to {
name = "ns-1488.awsdns-58.org"
}

delegate_to {
name = "ns-2034.awsdns-62.co.uk"
}

}
8 changes: 8 additions & 0 deletions examples/v0.14/Resources/ZoneDelegated/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
infoblox = {
source = "infobloxopen/infoblox"
version = ">= 2.1"
}
}
}
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.6.0
github.com/infobloxopen/infoblox-go-client/v2 v2.7.0
github.com/sirupsen/logrus v1.8.0
)

Expand Down
27 changes: 14 additions & 13 deletions infoblox/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"encoding/json"
"fmt"
"math"
"strings"
"time"

"github.com/google/uuid"
log "github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ibclient "github.com/infobloxopen/infoblox-go-client/v2"
"math"
"strings"
"time"
)

// Common parameters
Expand Down Expand Up @@ -66,7 +67,8 @@ func newInternalResourceIdFromString(id string) *internalResourceId {
if err != nil {
log.Error(context.Background(), "cannot parse internal ID", map[string]interface{}{
"internal ID": id,
"error": err.Error()})
"error": err.Error(),
})
return nil
}

Expand Down Expand Up @@ -204,6 +206,7 @@ func Provider() *schema.Provider {
"infoblox_aaaa_record": resourceAAAARecord(),
"infoblox_cname_record": resourceCNAMERecord(),
"infoblox_ptr_record": resourcePTRRecord(),
"infoblox_zone_delegated": resourceZoneDelegated(),
"infoblox_txt_record": resourceTXTRecord(),
"infoblox_mx_record": resourceMXRecord(),
"infoblox_srv_record": resourceSRVRecord(),
Expand All @@ -229,7 +232,6 @@ func Provider() *schema.Provider {
}

func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {

if d.Get("password") == "" {
return nil, diag.Diagnostics{diag.Diagnostic{
Severity: diag.Error,
Expand Down Expand Up @@ -319,7 +321,7 @@ func terraformDeserializeEAs(extAttrJSON string) (map[string]interface{}, error)
func omitEAs(niosEAs, terraformEAs map[string]interface{}) map[string]interface{} {
// ToDo: When EA inheritance is implemented on the go-client side, only inherited EAs should be omitted here.
res := niosEAs
for attrName, _ := range niosEAs {
for attrName := range niosEAs {
if _, ok := terraformEAs[attrName]; !ok {
delete(res, attrName)
}
Expand Down Expand Up @@ -401,9 +403,9 @@ func checkAndCreatePreRequisites(conn ibclient.IBConnector) error {
if isNotFoundError(err) {
// Create EA Definition
var EA ibclient.EADefinition
var ea_string = eaNameForInternalId
var flags = "CR"
var comment = "Internal ID for Terraform Resource"
ea_string := eaNameForInternalId
flags := "CR"
comment := "Internal ID for Terraform Resource"
EA.Name = &ea_string
EA.Type = "STRING"
EA.Flags = &flags
Expand All @@ -418,12 +420,11 @@ func checkAndCreatePreRequisites(conn ibclient.IBConnector) error {

// Fetch Resource using the Ref | Terraform Internal ID

//Func to search the object using the ref or internal_id

// Func to search the object using the ref or internal_id
func searchObjectByRefOrInternalId(objType string, d *schema.ResourceData, m interface{}) (
record interface{},
err error) {

err error,
) {
var (
ref string
actualIntId *internalResourceId
Expand Down
Loading