From 4121186b028b9f17b4e070cb1af3c2ad08f51441 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 18:16:32 +0530 Subject: [PATCH 01/23] feat(PDNS): update custom resolver profile and views --- ..._source_ibm_private_dns_custom_resolver.go | 14 ++ ...te_dns_custom_resolver_forwarding_rules.go | 31 +++++ .../resource_ibm_dns_linked_zone.go | 4 +- ...esource_ibm_private_dns_custom_resolver.go | 107 +++++++++++---- ...ate_dns_custom_resolver_forwarding_rule.go | 124 ++++++++++++++---- ...vate_dns_custom_resolver_secondary_zone.go | 4 +- .../resource_ibm_private_dns_glb.go | 17 ++- .../resource_ibm_private_dns_glb_monitor.go | 6 +- .../resource_ibm_private_dns_glb_pool.go | 9 +- ...ource_ibm_private_dns_permitted_network.go | 4 +- ...esource_ibm_private_dns_resource_record.go | 5 +- .../resource_ibm_private_dns_zones.go | 3 +- 12 files changed, 248 insertions(+), 80 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go index 49733eeabc..589a482f7f 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go @@ -51,6 +51,18 @@ func DataSourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeString, Computed: true, }, + pdnsCRProfile: { + Type: schema.TypeString, + Optional: true, + Default: "essential", + Description: "The profile name of the custom resolver.", + }, + pdnsCRAllowDisruptiveUpdates: { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether disruptive update is allowed for the custom resolver", + }, pdnsCustomResolverLocations: { Type: schema.TypeList, Description: "Locations on which the custom resolver will be running", @@ -109,6 +121,8 @@ func dataSourceIBMDNSCustomResolverRead(context context.Context, d *schema.Resou customResolver[pdnsCRDescription] = *instance.Description customResolver[pdnsCRHealth] = *instance.Health customResolver[pdnsCREnabled] = *instance.Enabled + customResolver[pdnsCRProfile] = *instance.Profile + customResolver[pdnsCRAllowDisruptiveUpdates] = *instance.AllowDisruptiveUpdates customResolver[pdnsCustomResolverLocations] = flattenPdnsCRLocations(instance.Locations) customResolvers = append(customResolvers, customResolver) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 25bcabd67c..272bc0fc03 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -61,6 +61,36 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { Type: schema.TypeString, }, }, + pdnsCRFRViews: { + Type: schema.TypeSet, + Description: "An array of views used by forwarding rules", + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Required: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Required: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Required: true, + Description: "The upstream DNS servers will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, @@ -91,6 +121,7 @@ func dataSourceIbmDnsCrForwardingRulesRead(context context.Context, d *schema.Re forwardRule[pdnsCRFRType] = *instance.Type forwardRule[pdnsCRFRMatch] = *instance.Match forwardRule[pdnsCRFRForwardTo] = instance.ForwardTo + forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) forwardRules = append(forwardRules, forwardRule) } diff --git a/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go b/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go index 16949e5b8c..2c83fcb86f 100644 --- a/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go +++ b/ibm/service/dnsservices/resource_ibm_dns_linked_zone.go @@ -120,12 +120,10 @@ func resourceIBMDNSLinkedZoneCreate(ctx context.Context, d *schema.ResourceData, } ownerInstanceID := d.Get(DnsLinkedZoneOwnerInstanceID).(string) ownerZoneID := d.Get(DnsLinkedZoneOwnerZoneID).(string) - createLinkedZoneOptions := sess.NewCreateLinkedZoneOptions(instanceID) + createLinkedZoneOptions := sess.NewCreateLinkedZoneOptions(instanceID, ownerInstanceID, ownerZoneID) createLinkedZoneOptions.SetDescription(description) createLinkedZoneOptions.SetLabel(label) - createLinkedZoneOptions.SetOwnerInstanceID(ownerInstanceID) - createLinkedZoneOptions.SetOwnerZoneID(ownerZoneID) mk := "dns_linked_zone_" + instanceID conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index 37d008baa5..924d231767 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -21,25 +21,27 @@ import ( ) const ( - ibmDNSCustomResolver = "ibm_dns_custom_resolver" - pdnsCustomResolvers = "custom_resolvers" - pdnsCustomResolverLocations = "locations" - pdnsCRId = "custom_resolver_id" - pdnsCRName = "name" - pdnsCRDescription = "description" - pdnsCRHealth = "health" - pdnsCREnabled = "enabled" - pdnsCRCreatedOn = "created_on" - pdnsCRModifiedOn = "modified_on" - pdnsCRLocationId = "location_id" - pdnsCRLocationSubnetCrn = "subnet_crn" - pdnsCRLocationEnabled = "enabled" - pdnsCRLocationHealthy = "healthy" - pdnsCRLocationDnsServerIp = "dns_server_ip" - pdnsCustomResolverCritical = "CRITICAL" - pdnsCustomResolverDegraded = "DEGRADED" - pdnsCustomResolverHealthy = "HEALTHY" - pdnsCRHighAvailability = "high_availability" + ibmDNSCustomResolver = "ibm_dns_custom_resolver" + pdnsCustomResolvers = "custom_resolvers" + pdnsCustomResolverLocations = "locations" + pdnsCRId = "custom_resolver_id" + pdnsCRName = "name" + pdnsCRDescription = "description" + pdnsCRHealth = "health" + pdnsCREnabled = "enabled" + pdnsCRCreatedOn = "created_on" + pdnsCRModifiedOn = "modified_on" + pdnsCRLocationId = "location_id" + pdnsCRLocationSubnetCrn = "subnet_crn" + pdnsCRLocationEnabled = "enabled" + pdnsCRLocationHealthy = "healthy" + pdnsCRLocationDnsServerIp = "dns_server_ip" + pdnsCustomResolverCritical = "CRITICAL" + pdnsCustomResolverDegraded = "DEGRADED" + pdnsCustomResolverHealthy = "HEALTHY" + pdnsCRHighAvailability = "high_availability" + pdnsCRProfile = "profile" + pdnsCRAllowDisruptiveUpdates = "allow_disruptive_updates" ) func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { @@ -132,6 +134,18 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { }, }, }, + pdnsCRProfile: { + Type: schema.TypeString, + Optional: true, + Default: "essential", + Description: "The profile name of the custom resolver.", + }, + pdnsCRAllowDisruptiveUpdates: { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether disruptive update is allowed for the custom resolver", + }, pdnsCRForwardRules: { Type: schema.TypeList, Computed: true, @@ -165,6 +179,36 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeString, }, }, + pdnsCRFRViews: { + Type: schema.TypeSet, + Description: "An array of views used by forwarding rules", + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Required: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Required: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Required: true, + Description: "The upstream DNS servers will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, }, }, @@ -205,10 +249,11 @@ func resouceIBMPrivateDNSCustomResolverCreate(context context.Context, d *schema if des, ok := d.GetOk(pdnsCRDescription); ok { crDescription = des.(string) } + crProfile := d.Get(pdnsCRProfile).(string) - customResolverOption := sess.NewCreateCustomResolverOptions(crn) - customResolverOption.SetName(crName) + customResolverOption := sess.NewCreateCustomResolverOptions(crn, crName) customResolverOption.SetDescription(crDescription) + customResolverOption.SetProfile(crProfile) cr_highaval := d.Get(pdnsCRHighAvailability).(bool) @@ -294,6 +339,7 @@ func resouceIBMPrivateDNSCustomResolverRead(context context.Context, d *schema.R forwardRule[pdnsCRFRType] = *instance.Type forwardRule[pdnsCRFRMatch] = *instance.Match forwardRule[pdnsCRFRForwardTo] = instance.ForwardTo + forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) forwardRules = append(forwardRules, forwardRule) } d.Set(pdnsInstanceID, crn) @@ -304,6 +350,8 @@ func resouceIBMPrivateDNSCustomResolverRead(context context.Context, d *schema.R d.Set(pdnsCREnabled, *result.Enabled) d.Set(pdnsCustomResolverLocations, flattenPdnsCRLocations(result.Locations)) d.Set(pdnsCRForwardRules, forwardRules) + d.Set(pdnsCRProfile, *result.Profile) + d.Set(pdnsCRAllowDisruptiveUpdates, *result.AllowDisruptiveUpdates) return nil } @@ -331,7 +379,9 @@ func resouceIBMPrivateDNSCustomResolverUpdate(context context.Context, d *schema if d.HasChange(pdnsCRName) || d.HasChange(pdnsCRDescription) || d.HasChange(pdnsCREnabled) || - d.HasChange(pdnsCRHighAvailability) { + d.HasChange(pdnsCRHighAvailability) || + d.HasChange(pdnsCRProfile) || + d.HasChange(pdnsCRAllowDisruptiveUpdates) { // Validation if _, ok := d.GetOk(pdnsCustomResolverLocations); ok { @@ -368,6 +418,14 @@ func resouceIBMPrivateDNSCustomResolverUpdate(context context.Context, d *schema if !cr_enable { opt.SetEnabled(false) } + if des, ok := d.GetOk(pdnsCRProfile); ok { + crProfile := des.(string) + opt.SetProfile(crProfile) + } + if des, ok := d.GetOk(pdnsCRAllowDisruptiveUpdates); ok { + crDisruptiveUpdates := des.(bool) + opt.SetAllowDisruptiveUpdates(crDisruptiveUpdates) + } result, resp, err := sess.UpdateCustomResolverWithContext(context, opt) if err != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the custom resolver %s:%s", err, resp)) @@ -491,7 +549,7 @@ func resouceIBMPrivateDNSCustomResolverDelete(context context.Context, d *schema optEnabled := sess.NewUpdateCustomResolverOptions(crn, customResolverID) optEnabled.SetEnabled(false) result, resp, errEnabled := sess.UpdateCustomResolverWithContext(context, optEnabled) - if err != nil || result == nil { + if errEnabled != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the custom resolver to disable before deleting %s:%s", errEnabled, resp)) } @@ -644,8 +702,7 @@ func addCRLocation(meta interface{}, instanceID string, customResolverID string, if err != nil { return "", diag.FromErr(err) } - opt := sess.NewAddCustomResolverLocationOptions(instanceID, customResolverID) - opt.SetSubnetCrn(subnet) + opt := sess.NewAddCustomResolverLocationOptions(instanceID, customResolverID, subnet) opt.SetEnabled(false) result, resp, err := sess.AddCustomResolverLocation(opt) locationID := *result.ID diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 4160058915..c67e27825e 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -11,21 +11,28 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/go-sdk-core/v5/core" + dns "github.com/IBM/networking-go-sdk/dnssvcsv1" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) const ( - pdnsCRForwardRule = "ibm_dns_custom_resolver_forwarding_rule" - pdnsCRForwardRules = "rules" - pdnsCRFRResolverID = "resolver_id" - pdnsCRFRDesctiption = "description" - pdnsCRFRType = "type" - pdnsCRFRMatch = "match" - pdnsCRFRForwardTo = "forward_to" - pdnsCRFRRuleID = "rule_id" - pdnsCRFRCreatedOn = "created_on" - pdnsCRFRModifiedOn = "modified_on" + pdnsCRForwardRule = "ibm_dns_custom_resolver_forwarding_rule" + pdnsCRForwardRules = "rules" + pdnsCRFRResolverID = "resolver_id" + pdnsCRFRDesctiption = "description" + pdnsCRFRType = "type" + pdnsCRFRMatch = "match" + pdnsCRFRForwardTo = "forward_to" + pdnsCRFRRuleID = "rule_id" + pdnsCRFRCreatedOn = "created_on" + pdnsCRFRModifiedOn = "modified_on" + pdnsCRFRViews = "views" + pdnsCRFRVName = "view_name" + pdnsCRFRVDescription = "view_description" + pdnsCRFRVExpression = "view_expression" + pdnsCRFRVForwardTo = "view_forward_to" ) func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { @@ -75,6 +82,36 @@ func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { Computed: true, Description: "the time when a forwarding rule ID is created, RFC3339 format.", }, + pdnsCRFRViews: { + Type: schema.TypeSet, + Description: "An array of views used by forwarding rules", + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + pdnsCRFRVName: { + Type: schema.TypeString, + Required: true, + Description: "Unique name of the view.", + }, + pdnsCRFRVDescription: { + Type: schema.TypeString, + Optional: true, + Description: "Description of the view.", + }, + pdnsCRFRVExpression: { + Type: schema.TypeString, + Required: true, + Description: "Expression of the view.", + }, + pdnsCRFRVForwardTo: { + Type: schema.TypeList, + Required: true, + Description: "The upstream DNS servers will be forwarded to.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, }, } } @@ -102,20 +139,28 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res } instanceID := d.Get(pdnsInstanceID).(string) resolverID := d.Get(pdnsCRFRResolverID).(string) - opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID) - if des, ok := d.GetOk(pdnsCRFRDesctiption); ok { - opt.SetDescription(des.(string)) - } - if t, ok := d.GetOk(pdnsCRFRType); ok { - opt.SetType(t.(string)) - } - if m, ok := d.GetOk(pdnsCRFRMatch); ok { - opt.SetMatch(m.(string)) - } - if _, ok := d.GetOk(pdnsCRFRForwardTo); ok { - opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + ruleType := d.Get(pdnsCRFRType).(string) + ruleMatch := d.Get(pdnsCRFRMatch).(string) + + views := d.Get(pdnsCRFRViews).(*schema.Set) + + var forwardingRuleInp dns.ForwardingRuleInputIntf + + if forward, ok := d.GetOk(pdnsCRFRForwardTo); ok { + if _, ok := d.GetOk(pdnsCRFRViews); ok { + forwardingRuleInp = new(dns.ForwardingRuleInputForwardingRuleBoth) + forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleBoth(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{})), expandPDNSFRViews(views)) + } else { + forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyForward(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{}))) + } + + } else { + forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyView(ruleType, ruleMatch, expandPDNSFRViews(views)) } + + opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID, forwardingRuleInp) + result, resp, err := dnsSvcsClient.CreateForwardingRuleWithContext(context, opt) if err != nil || result == nil { @@ -149,6 +194,7 @@ func resourceIbmDnsCrForwardingRuleRead(context context.Context, d *schema.Resou d.Set(pdnsCRFRType, *result.Type) d.Set(pdnsCRFRMatch, *result.Match) d.Set(pdnsCRFRForwardTo, result.ForwardTo) + d.Set(pdnsCRFRViews, flattenPDNSFRViews(result.Views)) return nil } @@ -166,7 +212,8 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res if d.HasChange(pdnsCRFRDesctiption) || d.HasChange(pdnsCRFRMatch) || - d.HasChange(pdnsCRFRForwardTo) { + d.HasChange(pdnsCRFRForwardTo) || + d.HasChange(pdnsCRFRViews) { if des, ok := d.GetOk(pdnsCRFRDesctiption); ok { frdesc := des.(string) opt.SetDescription(frdesc) @@ -183,6 +230,9 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res } } } + if view, ok := d.GetOk(pdnsCRFRViews); ok { + opt.SetViews(expandPDNSFRViews(view.(*schema.Set))) + } result, resp, err := dnsSvcsClient.UpdateForwardingRuleWithContext(context, opt) if err != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the forwarding rule %s:%s", err, resp)) @@ -209,3 +259,31 @@ func resourceIbmDnsCrForwardingRuleDelete(context context.Context, d *schema.Res d.SetId("") return nil } + +func expandPDNSFRViews(viewsList *schema.Set) (views []dns.ViewConfig) { + for _, viewElem := range viewsList.List() { + viewItem := viewElem.(map[string]interface{}) + view := dns.ViewConfig{ + Name: core.StringPtr(viewItem[pdnsCRFRVName].(string)), + Description: core.StringPtr(viewItem[pdnsCRFRVDescription].(string)), + Expression: core.StringPtr(viewItem[pdnsCRFRVExpression].(string)), + ForwardTo: flex.ExpandStringList(viewItem[pdnsCRFRVForwardTo].([]interface{})), + } + views = append(views, view) + } + return +} + +func flattenPDNSFRViews(list []dns.ViewConfig) []map[string]interface{} { + views := []map[string]interface{}{} + for _, view := range list { + l := map[string]interface{}{ + pdnsCRFRVName: *view.Name, + pdnsCRFRVExpression: *view.Expression, + pdnsCRFRVDescription: *view.Description, + pdnsCRFRVForwardTo: view.ForwardTo, + } + views = append(views, l) + } + return views +} diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go index 34245e1abc..3d15a66a5d 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_secondary_zone.go @@ -104,12 +104,10 @@ func resourceIBMPrivateDNSSecondaryZoneCreate(ctx context.Context, d *schema.Res enabled := d.Get(pdnsSecondaryZoneEnabled).(bool) transferFrom := flex.ExpandStringList(d.Get(pdnsSecondaryZoneTransferFrom).([]interface{})) - createSecondaryZoneOptions := sess.NewCreateSecondaryZoneOptions(instanceID, resolverID) + createSecondaryZoneOptions := sess.NewCreateSecondaryZoneOptions(instanceID, resolverID, zone, transferFrom) - createSecondaryZoneOptions.SetZone(zone) createSecondaryZoneOptions.SetDescription(description) createSecondaryZoneOptions.SetEnabled(enabled) - createSecondaryZoneOptions.SetTransferFrom(transferFrom) mk := "private_dns_secondary_zone_" + instanceID + resolverID conns.IbmMutexKV.Lock(mk) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb.go index 2c00fb54cf..f0c757feaf 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb.go @@ -152,12 +152,11 @@ func resourceIBMPrivateDNSGLBCreate(d *schema.ResourceData, meta interface{}) er } instanceID := d.Get(pdnsInstanceID).(string) zoneID := d.Get(pdnsZoneID).(string) - createlbOptions := sess.NewCreateLoadBalancerOptions(instanceID, zoneID) - lbname := d.Get(pdnsGLBName).(string) - createlbOptions.SetName(lbname) - createlbOptions.SetFallbackPool(d.Get(pdnsGLBFallbackPool).(string)) - createlbOptions.SetDefaultPools(flex.ExpandStringList(d.Get(pdnsGLBDefaultPool).([]interface{}))) + fallbackPool := d.Get(pdnsGLBFallbackPool).(string) + defaultPool := flex.ExpandStringList(d.Get(pdnsGLBDefaultPool).([]interface{})) + + createlbOptions := sess.NewCreateLoadBalancerOptions(instanceID, zoneID, lbname, fallbackPool, defaultPool) if description, ok := d.GetOk(pdnsGLBDescription); ok { createlbOptions.SetDescription(description.(string)) @@ -308,14 +307,14 @@ func resourceIBMPrivateDNSGLBExists(d *schema.ResourceData, meta interface{}) (b return true, nil } -func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.LoadBalancerAzPoolsItem, error) { +func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.AzPoolsItem, error) { azpools := azpool.(*schema.Set).List() - expandAZpools := make([]dnssvcsv1.LoadBalancerAzPoolsItem, 0) + expandAZpools := make([]dnssvcsv1.AzPoolsItem, 0) for _, v := range azpools { locationConfig := v.(map[string]interface{}) avzone := locationConfig[pdnsGLBAvailabilityZone].(string) pools := flex.ExpandStringList(locationConfig[pdnsGLBAZPoolsPools].([]interface{})) - aZItem := dnssvcsv1.LoadBalancerAzPoolsItem{ + aZItem := dnssvcsv1.AzPoolsItem{ AvailabilityZone: &avzone, Pools: pools, } @@ -324,7 +323,7 @@ func expandPDNSGlbAZPools(azpool interface{}) ([]dnssvcsv1.LoadBalancerAzPoolsIt return expandAZpools, nil } -func flattenPDNSGlbAZpool(azpool []dnssvcsv1.LoadBalancerAzPoolsItem) interface{} { +func flattenPDNSGlbAZpool(azpool []dnssvcsv1.AzPoolsItem) interface{} { flattened := make([]interface{}, 0) for _, v := range azpool { cfg := map[string]interface{}{ diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go index 7eea319b4d..ef2de87d78 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb_monitor.go @@ -226,13 +226,13 @@ func resourceIBMPrivateDNSGLBMonitorCreate(d *schema.ResourceData, meta interfac return err } instanceID := d.Get(pdnsInstanceID).(string) - createMonitorOptions := sess.NewCreateMonitorOptions(instanceID) - monitorname := d.Get(pdnsGlbMonitorName).(string) + + createMonitorOptions := sess.NewCreateMonitorOptions(instanceID, monitorname, "") + monitorinterval := int64(d.Get(pdnsGlbMonitorInterval).(int)) monitorretries := int64(d.Get(pdnsGlbMonitorRetries).(int)) monitortimeout := int64(d.Get(pdnsGlbMonitorTimeout).(int)) - createMonitorOptions.SetName(monitorname) createMonitorOptions.SetInterval(monitorinterval) createMonitorOptions.SetRetries(monitorretries) createMonitorOptions.SetTimeout(monitortimeout) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go b/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go index 0fc4cc2a65..5c65d660ad 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_glb_pool.go @@ -178,10 +178,10 @@ func resourceIBMPrivateDNSGLBPoolCreate(d *schema.ResourceData, meta interface{} } instanceID := d.Get(pdnsInstanceID).(string) - CreatePoolOptions := sess.NewCreatePoolOptions(instanceID) - poolname := d.Get(pdnsGlbPoolName).(string) - CreatePoolOptions.SetName(poolname) + poolorigins := d.Get(pdnsGlbPoolOrigins).(*schema.Set) + + CreatePoolOptions := sess.NewCreatePoolOptions(instanceID, poolname, expandPDNSGlbPoolOrigins(poolorigins)) if description, ok := d.GetOk(pdnsGlbPoolDescription); ok { CreatePoolOptions.SetDescription(description.(string)) @@ -206,9 +206,6 @@ func resourceIBMPrivateDNSGLBPoolCreate(d *schema.ResourceData, meta interface{} CreatePoolOptions.SetHealthcheckSubnets(flex.ExpandStringList(subnets.([]interface{}))) } - poolorigins := d.Get(pdnsGlbPoolOrigins).(*schema.Set) - CreatePoolOptions.SetOrigins(expandPDNSGlbPoolOrigins(poolorigins)) - result, resp, err := sess.CreatePool(CreatePoolOptions) if err != nil { log.Printf("create global load balancer pool failed %s", resp) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go b/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go index 43be78f08c..2856d8f557 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_permitted_network.go @@ -112,14 +112,12 @@ func resourceIBMPrivateDNSPermittedNetworkCreate(d *schema.ResourceData, meta in conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) - createPermittedNetworkOptions := sess.NewCreatePermittedNetworkOptions(instanceID, zoneID) permittedNetworkCrn, err := sess.NewPermittedNetworkVpc(vpcCRN) if err != nil { return err } + createPermittedNetworkOptions := sess.NewCreatePermittedNetworkOptions(instanceID, zoneID, nwType, permittedNetworkCrn) - createPermittedNetworkOptions.SetPermittedNetwork(permittedNetworkCrn) - createPermittedNetworkOptions.SetType(nwType) response, detail, err := sess.CreatePermittedNetwork(createPermittedNetworkOptions) if err != nil { return fmt.Errorf("[ERROR] Error creating pdns permitted network:%s\n%s", err, detail) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go b/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go index 4a0f4eb371..27bea25c40 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_resource_record.go @@ -229,9 +229,8 @@ func resourceIBMPrivateDNSResourceRecordCreate(d *schema.ResourceData, meta inte ttl = v.(int) } - createResourceRecordOptions := sess.NewCreateResourceRecordOptions(instanceID, zoneID) + createResourceRecordOptions := sess.NewCreateResourceRecordOptions(instanceID, zoneID, recordType) createResourceRecordOptions.SetName(name) - createResourceRecordOptions.SetType(recordType) createResourceRecordOptions.SetTTL(int64(ttl)) switch recordType { @@ -395,7 +394,7 @@ func resourceIBMPrivateDNSResourceRecordUpdate(d *schema.ResourceData, meta inte conns.IbmMutexKV.Lock(mk) defer conns.IbmMutexKV.Unlock(mk) - updateResourceRecordOptions := sess.NewUpdateResourceRecordOptions(idSet[0], idSet[1], idSet[2]) + updateResourceRecordOptions := sess.NewUpdateResourceRecordOptions(idSet[0], idSet[1], idSet[2], "", nil) var rdata string diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_zones.go b/ibm/service/dnsservices/resource_ibm_private_dns_zones.go index cb1676fa9a..9972c28b53 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_zones.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_zones.go @@ -115,8 +115,7 @@ func resourceIBMPrivateDNSZoneCreate(d *schema.ResourceData, meta interface{}) e if v, ok := d.GetOk(pdnsZoneLabel); ok { zoneLabel = v.(string) } - createZoneOptions := sess.NewCreateDnszoneOptions(instanceID) - createZoneOptions.SetName(zoneName) + createZoneOptions := sess.NewCreateDnszoneOptions(instanceID, zoneName) createZoneOptions.SetDescription(zoneDescription) createZoneOptions.SetLabel(zoneLabel) response, detail, err := sess.CreateDnszone(createZoneOptions) From 8df588a789253cb3c54d2a8e8b1b2402c424151d Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 18:21:06 +0530 Subject: [PATCH 02/23] fix minor warnigns --- .../data_source_ibm_private_dns_custom_resolver.go | 4 ++-- ...source_ibm_private_dns_custom_resolver_forwarding_rules.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go index 589a482f7f..76f92e0347 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go @@ -127,13 +127,13 @@ func dataSourceIBMDNSCustomResolverRead(context context.Context, d *schema.Resou customResolvers = append(customResolvers, customResolver) } - d.SetId(dataSourceIBMPrivateDNSCustomResolverID(d)) + d.SetId(dataSourceIBMPrivateDNSCustomResolverID()) d.Set(pdnsInstanceID, instanceID) d.Set(pdnsCustomResolvers, customResolvers) return nil } // dataSourceIBMPrivateDNSCustomResolverID returns a reasonable ID for dns custom resolver list. -func dataSourceIBMPrivateDNSCustomResolverID(d *schema.ResourceData) string { +func dataSourceIBMPrivateDNSCustomResolverID() string { return time.Now().UTC().String() } diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 272bc0fc03..69ccdcbbc0 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -125,13 +125,13 @@ func dataSourceIbmDnsCrForwardingRulesRead(context context.Context, d *schema.Re forwardRules = append(forwardRules, forwardRule) } - d.SetId(dataSourceIBMPrivateDNSForwardrulesID(d)) + d.SetId(dataSourceIBMPrivateDNSForwardrulesID()) d.Set(pdnsInstanceID, instanceID) d.Set(pdnsCRFRResolverID, resolverID) d.Set(pdnsCRForwardRules, forwardRules) return nil } -func dataSourceIBMPrivateDNSForwardrulesID(d *schema.ResourceData) string { +func dataSourceIBMPrivateDNSForwardrulesID() string { return time.Now().UTC().String() } From c379260923f16c88aca39d278ea0913033a31c0a Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 19:10:16 +0530 Subject: [PATCH 03/23] add example --- examples/ibm-private-dns/main.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/ibm-private-dns/main.tf b/examples/ibm-private-dns/main.tf index 297fe51dce..5d87f3ab5b 100644 --- a/examples/ibm-private-dns/main.tf +++ b/examples/ibm-private-dns/main.tf @@ -192,6 +192,8 @@ resource "ibm_dns_custom_resolver" "test" { name = "testCR-TF" instance_id = ibm_resource_instance.test-pdns-instance.guid description = "testdescription-CR" + profile = "essential" + allow_disruptive_updates = false locations { subnet_crn = "crn:v1:staging:public:is:us-south-1:a/01652b251c3ae2787110a995d8db0135::subnet:0716-6c3a997d-72b2-47f6-8788-6bd95e1bdb03" enabled = false @@ -203,6 +205,8 @@ resource "ibm_dns_custom_resolver" "test" { description = "new test CR TF-1" high_availability = true enabled = true + profile = "essential" + allow_disruptive_updates = false locations { subnet_crn = "crn:v1:staging:public:is:us-south-1:a/01652b251c3ae2787110a995d8db0135::subnet:0716-a094c4e8-02cd-4b04-858d-3432" enabled = false @@ -236,6 +240,12 @@ resource "ibm_dns_custom_resolver_forwarding_rule" "test" { type = "zone" match = "test.example.com" forward_to = ["168.20.22.122"] + views { + view_name = "view-example-name" + view_description = "view description" + view_expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + view_forward_to = ["10.240.2.6","10.240.2.7"] + } } data "ibm_dns_custom_resolver_forwarding_rules" "test-fr" { From d20fbf8ca1e394b6507504e244e9a7683f5f449e Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 21:23:34 +0530 Subject: [PATCH 04/23] add documentation --- ...om_resolver_forwarding_rules.html.markdown | 30 ++-- .../docs/d/dns_custom_resolvers.html.markdown | 40 ++--- .../docs/r/dns_custom_resolver.html.markdown | 137 ++++++++++-------- ...tom_resolver_forwarding_rule.html.markdown | 123 +++++++++------- 4 files changed, 179 insertions(+), 151 deletions(-) diff --git a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown index e2d7ef370d..c61ab94831 100644 --- a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown +++ b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown @@ -12,10 +12,10 @@ Provides a read-only data source for forwarding rules. You can then reference th ## Example usage - +```terraform data "ibm_dns_custom_resolver_forwarding_rules" "test-fr" { - instance_id = ibm_dns_custom_resolver.test.instance_id - resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id + instance_id = ibm_dns_custom_resolver.test.instance_id + resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id } ``` @@ -32,14 +32,16 @@ In addition to the argument references list, you can access the following attrib - `forwarding_rules` (List) List of forwarding rules. - Nested scheme for `forwarding_rules`: - - `description` - (String) Descriptive text of the forwarding rule. - - `forward_to` - (String) The upstream DNS servers will be forwarded to. - - `match` - (String) The matching zone or hostname. - - `rule_id` - (String) Identifier of the forwarding rule. - - `type` - (String) Type of the forwarding rule. - - - - - + Nested scheme for `forwarding_rules`: + - `description` - (String) Descriptive text of the forwarding rule. + - `forward_to` - (String) The upstream DNS servers will be forwarded to. + - `match` - (String) The matching zone or hostname. + - `rule_id` - (String) Identifier of the forwarding rule. + - `type` - (String) Type of the forwarding rule. + - `views` (List) List of views attached to the custom resolver. + + Nested scheme for `views`: + - `name` - (String) Name of the view. + - `description` - (String) Description of the view. + - `expression` - (String) Expression of the view. + - `forward_to` - (List) List of the upstream DNS servers will be forwarded to. diff --git a/website/docs/d/dns_custom_resolvers.html.markdown b/website/docs/d/dns_custom_resolvers.html.markdown index a8948d6e4a..450651223d 100644 --- a/website/docs/d/dns_custom_resolvers.html.markdown +++ b/website/docs/d/dns_custom_resolvers.html.markdown @@ -10,37 +10,39 @@ description: |- Provides a read-only data source for custom resolvers. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. For more information about custom resolver, refer to [List custom resolvers](https://cloud.ibm.com/apidocs/dns-svcs#list-custom-resolvers). - ## Example usage ```terraform data "ibm_dns_custom_resolvers" "test-cr" { - instance_id = ibm_dns_custom_resolver.test.instance_id + instance_id = ibm_dns_custom_resolver.test.instance_id } ``` ## Argument reference -Review the argument reference that you can specify for your data source. + +Review the argument reference that you can specify for your data source. - `instance_id` - (Required, String) The GUID of the private DNS service instance. ## Attribute reference -In addition to the argument references list, you can access the following attribute references after your data source is created. + +In addition to the argument references list, you can access the following attribute references after your data source is created. - `custom_resolvers` (List) List of all private DNS custom resolvers. - + Nested scheme for `custom_resolvers`: - - `custom_resolver_id` - (String) Identifier of the custom resolver. - - `description` - (String) Descriptive text of the custom resolver. - - `enabled` - (String) Whether custom resolver is enabled/disabled. - - `health`- (String) The status of DNS custom resolver's health. Supported values are `CRITICAL`, `DEGRADED`, `HEALTHY`. - - `name` - (String) Name of the custom resolver. - - `locations` (List) The list of locations within the custom resolver. - - Nested scheme for `locations`: - - `dns_server_ip`- (String) The DNS server IP. - - `enabled`- (String) Whether the location is enabled/disabled. - - `healthy`- (String) The health status. - - `location_id`- (String) The location ID. - - `subnet_crn` - (String) The subnet CRN. - + - `custom_resolver_id` - (String) Identifier of the custom resolver. + - `description` - (String) Descriptive text of the custom resolver. + - `enabled` - (String) Whether custom resolver is enabled/disabled. + - `health`- (String) The status of DNS custom resolver's health. Supported values are `CRITICAL`, `DEGRADED`, `HEALTHY`. + - `name` - (String) Name of the custom resolver. + - `profile` - (String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. + - `allow_disruptive_updates` - (Boolean) Whether disruptive update is allowed for the custom resolver. + - `locations` (List) The list of locations within the custom resolver. + + Nested scheme for `locations`: + - `dns_server_ip`- (String) The DNS server IP. + - `enabled`- (String) Whether the location is enabled/disabled. + - `healthy`- (String) The health status. + - `location_id`- (String) The location ID. + - `subnet_crn` - (String) The subnet CRN. diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index 5f948325b1..1802343c29 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -10,62 +10,62 @@ description: |- Provides a private DNS custom resolver resource. This allows DNS custom resolver to create, update, and delete. For more information, about customer resolver, see [create-custom-resolver](https://cloud.ibm.com/apidocs/dns-svcs#create-custom-resolver). - ## Example usage ```terraform - - data "ibm_resource_group" "rg" { - is_default = true - } - resource "ibm_is_vpc" "test-pdns-cr-vpc" { - name = "test-pdns-custom-resolver-vpc" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet1" { - name = "test-pdns-cr-subnet1" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.0.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet2" { - name = "test-pdns-cr-subnet2" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.64.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_resource_instance" "test-pdns-cr-instance" { - name = "test-pdns-cr-instance" - resource_group_id = data.ibm_resource_group.rg.id - location = "global" - service = "dns-svcs" - plan = "standard-dns" - } - resource "ibm_dns_custom_resolver" "test" { - name = "test-customresolver" - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - description = "new test CR - TF" - high_availability = true - enabled = true - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn - enabled = false - } - } + + data "ibm_resource_group" "rg" { + is_default = true + } + resource "ibm_is_vpc" "test-pdns-cr-vpc" { + name = "test-pdns-custom-resolver-vpc" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet1" { + name = "test-pdns-cr-subnet1" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.0.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet2" { + name = "test-pdns-cr-subnet2" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.64.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_resource_instance" "test-pdns-cr-instance" { + name = "test-pdns-cr-instance" + resource_group_id = data.ibm_resource_group.rg.id + location = "global" + service = "dns-svcs" + plan = "standard-dns" + } + resource "ibm_dns_custom_resolver" "test" { + name = "test-customresolver" + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + description = "new test CR - TF" + high_availability = true + enabled = true + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + enabled = false + } + } ``` ## Argument reference -Review the argument reference that you can specify for your resource. + +Review the argument reference that you can specify for your resource. - `instance_id` - (Required, String) The GUID of the private DNS service instance. - `name`- (Required, String) The name of the custom resolver. @@ -75,12 +75,15 @@ Review the argument reference that you can specify for your resource. - `locations`- (Optional, List) The list of locations where this custom resolver is deployed. A custom resolver can have a maximum of three locations, either within the same subnet or in different subnets. ## Attribute reference -In addition to all argument reference list, you can access the following attribute references after your resource is created. -- `created_on` - (Timestamp) The time (created On) of the DNS Custom Resolver. +In addition to all argument reference list, you can access the following attribute references after your resource is created. + +- `created_on` - (Timestamp) The time (created On) of the DNS Custom Resolver. - `custom_resolver_id` - (String) The unique ID of the private DNS custom resolver. - `modified_on` - (Timestamp) The time (modified On) of the DNS Custom Resolver. - `health`- (String) The status of DNS Custom Resolver's health. Possible values are `DEGRADED`, `CRITICAL`, `HEALTHY`. +- `profile` - (String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. +- `allow_disruptive_updates` - (Boolean) Whether disruptive update is allowed for the custom resolver. - `locations` - (List) Locations on which the custom resolver will be running. Nested scheme for `locations`: @@ -89,23 +92,31 @@ In addition to all argument reference list, you can access the following attribu - `enabled`- (Bool) Whether the location is enabled. - `location_id`- (String) The location ID. - Nested scheme for `rules`: - - `rule_id` - (String) The rule ID is unique identifier of the custom resolver forwarding rule. - - `description`- (String) Descriptive text of the forwarding rule. - - `type` - (String) Type of the forwarding rule.Constraints: Allowable values are: `zone`, `hostname`. - - `match` - (String) The matching zone or hostname. - - `forward_to` - (List) The upstream DNS servers will be forwarded to. + Nested scheme for `rules`: + - `rule_id` - (String) The rule ID is unique identifier of the custom resolver forwarding rule. + - `description`- (String) Descriptive text of the forwarding rule. + - `type` - (String) Type of the forwarding rule.Constraints: Allowable values are: `zone`, `hostname`. + - `match` - (String) The matching zone or hostname. + - `forward_to` - (List) The upstream DNS servers will be forwarded to. + - `views` (List) List of views attached to the custom resolver. + + Nested scheme for `views`: + - `name` - (String) Name of the view. + - `description` - (String) Description of the view. + - `expression` - (String) Expression of the view. + - `forward_to` - (List) List of the upstream DNS servers will be forwarded to. ## Import + The `ibm_dns_custom_resolver` can be imported by using private DNS instance ID, Custom Resolver ID. The `id` property can be formed from `custom_resolver_id` and `instance_id` in the following format: -``` -: +```terraform +terraform import ibm_dns_custom_resolver.example : ``` -**Example** +### Example -``` -$ terraform import ibm_dns_custom_resolver.example 270edfad-8574-4ce0-86bf-5c158d3e38fe:345ca2c4-83bf-4c04-bb09-5d8ec4d425a8 +```terraform +terraform import ibm_dns_custom_resolver.example 270edfad-8574-4ce0-86bf-5c158d3e38fe:345ca2c4-83bf-4c04-bb09-5d8ec4d425a8 ``` diff --git a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown index 857289bf5e..8fcb72b031 100644 --- a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown +++ b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown @@ -13,57 +13,62 @@ Provides a resource for ibm_dns_custom_resolver_forwarding_rule. This allows For ## Example usage ```terraform - - data "ibm_resource_group" "rg" { - is_default = true - } - resource "ibm_is_vpc" "test-pdns-cr-vpc" { - name = "test-pdns-custom-resolver-vpc" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet1" { - name = "test-pdns-cr-subnet1" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.0.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_is_subnet" "test-pdns-cr-subnet2" { - name = "test-pdns-cr-subnet2" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.64.0/24" - resource_group = data.ibm_resource_group.rg.id - } - resource "ibm_resource_instance" "test-pdns-cr-instance" { - name = "test-pdns-cr-instance" - resource_group_id = data.ibm_resource_group.rg.id - location = "global" - service = "dns-svcs" - plan = "standard-dns" - } - resource "ibm_dns_custom_resolver" "test" { - name = "test-customresolver" - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - description = "new test CR - TF" - enabled = true - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true - } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn - enabled = true - } - } - resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id - description = "Test Fw Rule" - type = "zone" - match = "test.example.com" - forward_to = ["168.20.22.122"] - } +data "ibm_resource_group" "rg" { + is_default = true +} +resource "ibm_is_vpc" "test-pdns-cr-vpc" { + name = "test-pdns-custom-resolver-vpc" + resource_group = data.ibm_resource_group.rg.id +} +resource "ibm_is_subnet" "test-pdns-cr-subnet1" { + name = "test-pdns-cr-subnet1" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.0.0/24" + resource_group = data.ibm_resource_group.rg.id +} +resource "ibm_is_subnet" "test-pdns-cr-subnet2" { + name = "test-pdns-cr-subnet2" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.64.0/24" + resource_group = data.ibm_resource_group.rg.id +} +resource "ibm_resource_instance" "test-pdns-cr-instance" { + name = "test-pdns-cr-instance" + resource_group_id = data.ibm_resource_group.rg.id + location = "global" + service = "dns-svcs" + plan = "standard-dns" +} +resource "ibm_dns_custom_resolver" "test" { + name = "test-customresolver" + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + description = "new test CR - TF" + enabled = true + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + enabled = true + } +} +resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id + description = "Test Fw Rule" + type = "zone" + match = "test.example.com" + forward_to = ["168.20.22.122"] + views { + name = "view-example-1" + description = "view example 1" + expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + forward_to = ["10.240.2.6","10.240.2.7"] + } +} ``` ## Argument reference @@ -77,6 +82,13 @@ Review the argument reference that you can specify for your resource. * Constraints: Allowable values is: zone. * `match` - (Optional, String) The matching zone or hostname. * `forward_to` - (Optional, List) The upstream DNS servers will be forwarded to. +* `views` (List) List of views attached to the custom resolver. + + Nested scheme for `views`: + * `name` - (String) Name of the view. + * `description` - (String) Description of the view. + * `expression` - (String) Expression of the view. + * `forward_to` - (List) List of the upstream DNS servers will be forwarded to. ## Attribute reference @@ -92,13 +104,14 @@ In addition to all argument reference list, you can access the following attribu You can import the `ibm_dns_custom_resolver_forwarding_rule` resource by using `id`. The `id` property can be formed from `rule_id`, `resolver_id`, and `instance_id` in the following format: +```terraform +terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: ``` -:: -``` + * `rule_id`: A String. The unique identifier of a forwarding rule. * `resolver_id`: A String. The unique identifier of a custom resolver. * `instance_id`: A String. The GUID of the private DNS service instance. -``` -$ terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: +```terraform +terraform import ibm_dns_custom_resolver_forwarding_rule.ibm_dns_custom_resolver_forwarding_rule :: ``` From afb56ac1c6f5ca87126bd09a9e4d3c50cb1ea21c Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 21:23:59 +0530 Subject: [PATCH 05/23] change variable names --- ...rce_ibm_private_dns_custom_resolver_forwarding_rule.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index c67e27825e..cfcfcca363 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -29,10 +29,10 @@ const ( pdnsCRFRCreatedOn = "created_on" pdnsCRFRModifiedOn = "modified_on" pdnsCRFRViews = "views" - pdnsCRFRVName = "view_name" - pdnsCRFRVDescription = "view_description" - pdnsCRFRVExpression = "view_expression" - pdnsCRFRVForwardTo = "view_forward_to" + pdnsCRFRVName = "name" + pdnsCRFRVDescription = "description" + pdnsCRFRVExpression = "expression" + pdnsCRFRVForwardTo = "forward_to" ) func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { From dc780d6f49876f43796f69c14b1643b84b570cf6 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 21:39:47 +0530 Subject: [PATCH 06/23] fix styling --- ...tom_resolver_forwarding_rule.html.markdown | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown index 8fcb72b031..7fdd29071a 100644 --- a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown +++ b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown @@ -13,62 +13,62 @@ Provides a resource for ibm_dns_custom_resolver_forwarding_rule. This allows For ## Example usage ```terraform -data "ibm_resource_group" "rg" { - is_default = true -} -resource "ibm_is_vpc" "test-pdns-cr-vpc" { - name = "test-pdns-custom-resolver-vpc" - resource_group = data.ibm_resource_group.rg.id -} -resource "ibm_is_subnet" "test-pdns-cr-subnet1" { - name = "test-pdns-cr-subnet1" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.0.0/24" - resource_group = data.ibm_resource_group.rg.id -} -resource "ibm_is_subnet" "test-pdns-cr-subnet2" { - name = "test-pdns-cr-subnet2" - vpc = ibm_is_vpc.test-pdns-cr-vpc.id - zone = "us-south-1" - ipv4_cidr_block = "10.240.64.0/24" - resource_group = data.ibm_resource_group.rg.id -} -resource "ibm_resource_instance" "test-pdns-cr-instance" { - name = "test-pdns-cr-instance" - resource_group_id = data.ibm_resource_group.rg.id - location = "global" - service = "dns-svcs" - plan = "standard-dns" -} -resource "ibm_dns_custom_resolver" "test" { - name = "test-customresolver" - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - description = "new test CR - TF" - enabled = true - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn - enabled = true + data "ibm_resource_group" "rg" { + is_default = true } - locations { - subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + resource "ibm_is_vpc" "test-pdns-cr-vpc" { + name = "test-pdns-custom-resolver-vpc" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet1" { + name = "test-pdns-cr-subnet1" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.0.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_is_subnet" "test-pdns-cr-subnet2" { + name = "test-pdns-cr-subnet2" + vpc = ibm_is_vpc.test-pdns-cr-vpc.id + zone = "us-south-1" + ipv4_cidr_block = "10.240.64.0/24" + resource_group = data.ibm_resource_group.rg.id + } + resource "ibm_resource_instance" "test-pdns-cr-instance" { + name = "test-pdns-cr-instance" + resource_group_id = data.ibm_resource_group.rg.id + location = "global" + service = "dns-svcs" + plan = "standard-dns" + } + resource "ibm_dns_custom_resolver" "test" { + name = "test-customresolver" + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + description = "new test CR - TF" enabled = true + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn + enabled = true + } + locations { + subnet_crn = ibm_is_subnet.test-pdns-cr-subnet2.crn + enabled = true + } } -} -resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { - instance_id = ibm_resource_instance.test-pdns-cr-instance.guid - resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id - description = "Test Fw Rule" - type = "zone" - match = "test.example.com" - forward_to = ["168.20.22.122"] - views { - name = "view-example-1" - description = "view example 1" - expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" - forward_to = ["10.240.2.6","10.240.2.7"] + resource "ibm_dns_custom_resolver_forwarding_rule" "dns_custom_resolver_forwarding_rule" { + instance_id = ibm_resource_instance.test-pdns-cr-instance.guid + resolver_id = ibm_dns_custom_resolver.test.custom_resolver_id + description = "Test Fw Rule" + type = "zone" + match = "test.example.com" + forward_to = ["168.20.22.122"] + views { + name = "view-example-1" + description = "view example 1" + expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + forward_to = ["10.240.2.6","10.240.2.7"] + } } -} ``` ## Argument reference From a04bd5544e4aefd0dbe0db95fe7732d3ed0b00fe Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 6 Sep 2024 21:45:16 +0530 Subject: [PATCH 07/23] add validator for profile --- ibm/provider/provider.go | 1 + ...esource_ibm_private_dns_custom_resolver.go | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index dc4a116869..0af9198ba2 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -1863,6 +1863,7 @@ func Validator() validate.ValidatorDict { "ibm_is_reservation": vpc.ResourceIBMISReservationValidator(), "ibm_kms_key_rings": kms.ResourceIBMKeyRingValidator(), "ibm_dns_glb_monitor": dnsservices.ResourceIBMPrivateDNSGLBMonitorValidator(), + "ibm_dns_custom_resolver": dnsservices.ResourceIBMPrivateDNSCustomResolverValidator(), "ibm_dns_custom_resolver_forwarding_rule": dnsservices.ResourceIBMPrivateDNSForwardingRuleValidator(), "ibm_schematics_action": schematics.ResourceIBMSchematicsActionValidator(), "ibm_schematics_job": schematics.ResourceIBMSchematicsJobValidator(), diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index 924d231767..eb34e12b01 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -13,6 +13,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" "github.com/IBM/networking-go-sdk/dnssvcsv1" "github.com/IBM/go-sdk-core/v5/core" @@ -135,10 +136,11 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { }, }, pdnsCRProfile: { - Type: schema.TypeString, - Optional: true, - Default: "essential", - Description: "The profile name of the custom resolver.", + Type: schema.TypeString, + Optional: true, + Default: "essential", + Description: "The profile name of the custom resolver.", + ValidateFunc: validate.InvokeValidator(ibmDNSCustomResolver, pdnsCRProfile), }, pdnsCRAllowDisruptiveUpdates: { Type: schema.TypeBool, @@ -227,6 +229,21 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { } } +func ResourceIBMPrivateDNSCustomResolverValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: pdnsCRProfile, + ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, + Type: validate.TypeString, + Optional: true, + AllowedValues: "essential, advanced, premier", + }, + ) + resourceValidator := validate.ResourceValidator{ResourceName: ibmDNSCustomResolver, Schema: validateSchema} + return &resourceValidator +} + type location struct { locationId string subnet string From 3ba50121b593385df20af063df8fa637fc39b194 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sat, 7 Sep 2024 17:53:25 +0530 Subject: [PATCH 08/23] modify example --- examples/ibm-private-dns/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ibm-private-dns/main.tf b/examples/ibm-private-dns/main.tf index 5d87f3ab5b..442d4c5eb0 100644 --- a/examples/ibm-private-dns/main.tf +++ b/examples/ibm-private-dns/main.tf @@ -241,10 +241,10 @@ resource "ibm_dns_custom_resolver_forwarding_rule" "test" { match = "test.example.com" forward_to = ["168.20.22.122"] views { - view_name = "view-example-name" - view_description = "view description" - view_expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" - view_forward_to = ["10.240.2.6","10.240.2.7"] + name = "view-example-name" + description = "view description" + expression = "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" + forward_to = ["10.240.2.6","10.240.2.7"] } } From 1097e5b0b6a7330dac53fd4daaf355776880e7dd Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sun, 22 Sep 2024 21:29:15 +0530 Subject: [PATCH 09/23] improve error message --- ...esource_ibm_private_dns_custom_resolver_forwarding_rule.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index cfcfcca363..6829379b46 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -156,7 +156,9 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res } } else { - forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyView(ruleType, ruleMatch, expandPDNSFRViews(views)) + if _, ok := d.GetOk(pdnsCRFRViews); !ok { + return diag.FromErr(fmt.Errorf("[ERROR] Can not creating the forwarding rules. One of the field from forward_to or views must be provided.")) + } } opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID, forwardingRuleInp) From 8d124a4ff587294c4cc72c7c35af1f85e996254d Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Mon, 23 Sep 2024 14:47:46 +0530 Subject: [PATCH 10/23] modified docs --- website/docs/r/dns_custom_resolver.html.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index 1802343c29..86198f1716 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -48,6 +48,8 @@ Provides a private DNS custom resolver resource. This allows DNS custom resolver description = "new test CR - TF" high_availability = true enabled = true + profile = "essential" + allow_disruptive_updates = false locations { subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn enabled = true @@ -73,6 +75,8 @@ Review the argument reference that you can specify for your resource. - `description` - (Optional, String) Descriptive text of the custom resolver. - `high_availability` - (Optional, Bool) High Availability is enabled by Default. To meet high availability status, configure custom resolvers with a minimum of two resolver locations. - `locations`- (Optional, List) The list of locations where this custom resolver is deployed. A custom resolver can have a maximum of three locations, either within the same subnet or in different subnets. +- `profile` - (Optional, String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. Default value is `ESSENTIAL`. +- `allow_disruptive_updates` - (Optional, Boolean) Whether disruptive update is allowed for the custom resolver. Default value is false. ## Attribute reference @@ -82,8 +86,6 @@ In addition to all argument reference list, you can access the following attribu - `custom_resolver_id` - (String) The unique ID of the private DNS custom resolver. - `modified_on` - (Timestamp) The time (modified On) of the DNS Custom Resolver. - `health`- (String) The status of DNS Custom Resolver's health. Possible values are `DEGRADED`, `CRITICAL`, `HEALTHY`. -- `profile` - (String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. -- `allow_disruptive_updates` - (Boolean) Whether disruptive update is allowed for the custom resolver. - `locations` - (List) Locations on which the custom resolver will be running. Nested scheme for `locations`: From 31780cef0b0bc957ee42f72818429a4c789c5707 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Mon, 23 Sep 2024 14:49:52 +0530 Subject: [PATCH 11/23] fix error message --- .../resource_ibm_private_dns_custom_resolver_forwarding_rule.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 6829379b46..0da61cd2ec 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -157,7 +157,7 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res } else { if _, ok := d.GetOk(pdnsCRFRViews); !ok { - return diag.FromErr(fmt.Errorf("[ERROR] Can not creating the forwarding rules. One of the field from forward_to or views must be provided.")) + return diag.FromErr(fmt.Errorf("[ERROR] Can not create the forwarding rules. One of the field from forward_to or views must be provided.")) } } From b7ed734e0178f8b75de7090182ad6385a4cf0cec Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sun, 13 Oct 2024 22:23:45 +0530 Subject: [PATCH 12/23] incorporate review comments for documentation --- .../data_source_ibm_private_dns_custom_resolver.go | 2 +- .../resource_ibm_private_dns_custom_resolver.go | 2 +- ...bm_private_dns_custom_resolver_forwarding_rule.go | 2 +- ...ns_custom_resolver_forwarding_rules.html.markdown | 4 ++-- website/docs/d/dns_custom_resolvers.html.markdown | 8 ++++---- website/docs/r/dns_custom_resolver.html.markdown | 3 ++- ...dns_custom_resolver_forwarding_rule.html.markdown | 12 ++++++------ 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go index 76f92e0347..8ca4fe77d4 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go @@ -61,7 +61,7 @@ func DataSourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - Description: "Whether disruptive update is allowed for the custom resolver", + Description: "Whether a disruptive update is allowed for the custom resolver", }, pdnsCustomResolverLocations: { Type: schema.TypeList, diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index eb34e12b01..ab83a6384e 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -146,7 +146,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - Description: "Whether disruptive update is allowed for the custom resolver", + Description: "Whether a disruptive update is allowed for the custom resolver", }, pdnsCRForwardRules: { Type: schema.TypeList, diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 0da61cd2ec..3ae053dcb8 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -157,7 +157,7 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res } else { if _, ok := d.GetOk(pdnsCRFRViews); !ok { - return diag.FromErr(fmt.Errorf("[ERROR] Can not create the forwarding rules. One of the field from forward_to or views must be provided.")) + return diag.FromErr(fmt.Errorf("[ERROR] Cannot create the forwarding rules. One of the fields from forward_to or views must be provided.")) } } diff --git a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown index c61ab94831..d1cabd42d2 100644 --- a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown +++ b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown @@ -34,7 +34,7 @@ In addition to the argument references list, you can access the following attrib Nested scheme for `forwarding_rules`: - `description` - (String) Descriptive text of the forwarding rule. - - `forward_to` - (String) The upstream DNS servers will be forwarded to. + - `forward_to` - (List) List of the upstream DNS that the servers will be forwarded to. - `match` - (String) The matching zone or hostname. - `rule_id` - (String) Identifier of the forwarding rule. - `type` - (String) Type of the forwarding rule. @@ -44,4 +44,4 @@ In addition to the argument references list, you can access the following attrib - `name` - (String) Name of the view. - `description` - (String) Description of the view. - `expression` - (String) Expression of the view. - - `forward_to` - (List) List of the upstream DNS servers will be forwarded to. + - `forward_to` - (List) List of the upstream DNS that the servers will be forwarded to. diff --git a/website/docs/d/dns_custom_resolvers.html.markdown b/website/docs/d/dns_custom_resolvers.html.markdown index 450651223d..e5c3d10625 100644 --- a/website/docs/d/dns_custom_resolvers.html.markdown +++ b/website/docs/d/dns_custom_resolvers.html.markdown @@ -8,7 +8,7 @@ description: |- # ibm_dns_custom_resolvers -Provides a read-only data source for custom resolvers. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. For more information about custom resolver, refer to [List custom resolvers](https://cloud.ibm.com/apidocs/dns-svcs#list-custom-resolvers). +Provides a read-only data source for custom resolvers. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. For more information about custom resolver, see [List custom resolvers](https://cloud.ibm.com/apidocs/dns-svcs#list-custom-resolvers). ## Example usage @@ -33,16 +33,16 @@ In addition to the argument references list, you can access the following attrib Nested scheme for `custom_resolvers`: - `custom_resolver_id` - (String) Identifier of the custom resolver. - `description` - (String) Descriptive text of the custom resolver. - - `enabled` - (String) Whether custom resolver is enabled/disabled. + - `enabled` - (String) Whether the custom resolver is enabled or disabled. - `health`- (String) The status of DNS custom resolver's health. Supported values are `CRITICAL`, `DEGRADED`, `HEALTHY`. - `name` - (String) Name of the custom resolver. - `profile` - (String) The profile name of the custom resolver. Supported values are `ESSENTIAL`, `ADVANCED`, `PREMIER`. - - `allow_disruptive_updates` - (Boolean) Whether disruptive update is allowed for the custom resolver. + - `allow_disruptive_updates` - (Boolean) Whether a disruptive update is allowed for the custom resolver. - `locations` (List) The list of locations within the custom resolver. Nested scheme for `locations`: - `dns_server_ip`- (String) The DNS server IP. - - `enabled`- (String) Whether the location is enabled/disabled. + - `enabled`- (String) Whether the location is enabled or disabled. - `healthy`- (String) The health status. - `location_id`- (String) The location ID. - `subnet_crn` - (String) The subnet CRN. diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index 86198f1716..ef4da81f05 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -97,7 +97,8 @@ In addition to all argument reference list, you can access the following attribu Nested scheme for `rules`: - `rule_id` - (String) The rule ID is unique identifier of the custom resolver forwarding rule. - `description`- (String) Descriptive text of the forwarding rule. - - `type` - (String) Type of the forwarding rule.Constraints: Allowable values are: `zone`, `hostname`. + - `type` - (String) Type of the forwarding rule. + - Constraints: Allowable values are: `zone`, `hostname`. - `match` - (String) The matching zone or hostname. - `forward_to` - (List) The upstream DNS servers will be forwarded to. - `views` (List) List of views attached to the custom resolver. diff --git a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown index 7fdd29071a..111f6b8581 100644 --- a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown +++ b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown @@ -79,16 +79,16 @@ Review the argument reference that you can specify for your resource. * `resolver_id` - (Required, String) The unique identifier of a custom resolver. * `description` - (Optional, String) Descriptive text of the forwarding rule. * `type` - (Optional, String) Type of the forwarding rule. - * Constraints: Allowable values is: zone. + * Constraints: Allowable values is: `zone`. * `match` - (Optional, String) The matching zone or hostname. * `forward_to` - (Optional, List) The upstream DNS servers will be forwarded to. -* `views` (List) List of views attached to the custom resolver. +* `views` (Optional, List) List of views attached to the custom resolver. Nested scheme for `views`: - * `name` - (String) Name of the view. - * `description` - (String) Description of the view. - * `expression` - (String) Expression of the view. - * `forward_to` - (List) List of the upstream DNS servers will be forwarded to. + * `name` - (Required, String) Name of the view. + * `description` - (optional, String) Description of the view. + * `expression` - (Required, String) Expression of the view. + * `forward_to` - (Required, List) List of the upstream DNS servers will be forwarded to. ## Attribute reference From 57c87c04d2f8440752f99cd01d5448f8890b94b1 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Wed, 16 Oct 2024 16:14:29 +0530 Subject: [PATCH 13/23] add order in views and fix minor bugs --- ...te_dns_custom_resolver_forwarding_rules.go | 18 +++++----- ...esource_ibm_private_dns_custom_resolver.go | 2 +- ...ate_dns_custom_resolver_forwarding_rule.go | 35 ++++++++++++------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 69ccdcbbc0..3766e9e849 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -62,7 +62,7 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { }, }, pdnsCRFRViews: { - Type: schema.TypeSet, + Type: schema.TypeList, Description: "An array of views used by forwarding rules", Optional: true, Elem: &schema.Resource{ @@ -115,15 +115,15 @@ func dataSourceIbmDnsCrForwardingRulesRead(context context.Context, d *schema.Re forwardRules := make([]interface{}, 0) for _, instance := range result.ForwardingRules { - forwardRule := map[string]interface{}{} - forwardRule[pdnsCRFRRuleID] = *instance.ID - forwardRule[pdnsCRFRDesctiption] = *instance.Description - forwardRule[pdnsCRFRType] = *instance.Type - forwardRule[pdnsCRFRMatch] = *instance.Match - forwardRule[pdnsCRFRForwardTo] = instance.ForwardTo - forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) + fwdRule := map[string]interface{}{} + fwdRule[pdnsCRFRRuleID] = *instance.ID + fwdRule[pdnsCRFRDesctiption] = *instance.Description + fwdRule[pdnsCRFRType] = *instance.Type + fwdRule[pdnsCRFRMatch] = *instance.Match + fwdRule[pdnsCRFRForwardTo] = instance.ForwardTo + fwdRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) - forwardRules = append(forwardRules, forwardRule) + forwardRules = append(forwardRules, fwdRule) } d.SetId(dataSourceIBMPrivateDNSForwardrulesID()) d.Set(pdnsInstanceID, instanceID) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index ab83a6384e..b5d2adb00a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -182,7 +182,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { }, }, pdnsCRFRViews: { - Type: schema.TypeSet, + Type: schema.TypeList, Description: "An array of views used by forwarding rules", Optional: true, Elem: &schema.Resource{ diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 3ae053dcb8..fb2f94c55a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -83,7 +83,7 @@ func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { Description: "the time when a forwarding rule ID is created, RFC3339 format.", }, pdnsCRFRViews: { - Type: schema.TypeSet, + Type: schema.TypeList, Description: "An array of views used by forwarding rules", Optional: true, Elem: &schema.Resource{ @@ -142,27 +142,38 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res ruleType := d.Get(pdnsCRFRType).(string) ruleMatch := d.Get(pdnsCRFRMatch).(string) + ruleDescription := d.Get(pdnsCRFRDesctiption).(string) - views := d.Get(pdnsCRFRViews).(*schema.Set) + views := d.Get(pdnsCRFRViews).([]interface{}) var forwardingRuleInp dns.ForwardingRuleInputIntf + opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID, forwardingRuleInp) + // If forward_to field is present then we check if views are also present or not. + // We call the respective functions depending upon the availibility of the views. + // We follow the same approach when forward_to is not present. In this case if views are also not present then we throw an error. if forward, ok := d.GetOk(pdnsCRFRForwardTo); ok { if _, ok := d.GetOk(pdnsCRFRViews); ok { - forwardingRuleInp = new(dns.ForwardingRuleInputForwardingRuleBoth) - forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleBoth(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{})), expandPDNSFRViews(views)) + forwardingRuleInpBoth, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleBoth(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{})), expandPDNSFRViews(views)) + forwardingRuleInpBoth.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpBoth) + } else { - forwardingRuleInp, _ = dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyForward(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{}))) + forwardingRuleInpOnlyRule, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyForward(ruleType, ruleMatch, flex.ExpandStringList(forward.([]interface{}))) + forwardingRuleInpOnlyRule.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpOnlyRule) } - + // forward_to not present } else { - if _, ok := d.GetOk(pdnsCRFRViews); !ok { + if _, ok := d.GetOk(pdnsCRFRViews); ok { + forwardingRuleInpOnlyView, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyView(ruleType, ruleMatch, expandPDNSFRViews(views)) + forwardingRuleInpOnlyView.Description = &ruleDescription + opt.SetForwardingRuleInput(forwardingRuleInpOnlyView) + } else { return diag.FromErr(fmt.Errorf("[ERROR] Cannot create the forwarding rules. One of the fields from forward_to or views must be provided.")) } } - opt := dnsSvcsClient.NewCreateForwardingRuleOptions(instanceID, resolverID, forwardingRuleInp) - result, resp, err := dnsSvcsClient.CreateForwardingRuleWithContext(context, opt) if err != nil || result == nil { @@ -233,7 +244,7 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res } } if view, ok := d.GetOk(pdnsCRFRViews); ok { - opt.SetViews(expandPDNSFRViews(view.(*schema.Set))) + opt.SetViews(expandPDNSFRViews(view.([]interface{}))) } result, resp, err := dnsSvcsClient.UpdateForwardingRuleWithContext(context, opt) if err != nil || result == nil { @@ -262,8 +273,8 @@ func resourceIbmDnsCrForwardingRuleDelete(context context.Context, d *schema.Res return nil } -func expandPDNSFRViews(viewsList *schema.Set) (views []dns.ViewConfig) { - for _, viewElem := range viewsList.List() { +func expandPDNSFRViews(viewsList []interface{}) (views []dns.ViewConfig) { + for _, viewElem := range viewsList { viewItem := viewElem.(map[string]interface{}) view := dns.ViewConfig{ Name: core.StringPtr(viewItem[pdnsCRFRVName].(string)), From 50bbf8e067078ae6faaba9e9c0f74c3a5d6592b2 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Wed, 16 Oct 2024 21:04:58 +0530 Subject: [PATCH 14/23] change the variable instance --- ...ate_dns_custom_resolver_forwarding_rules.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 3766e9e849..54dfc108cd 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -114,16 +114,16 @@ func dataSourceIbmDnsCrForwardingRulesRead(context context.Context, d *schema.Re } forwardRules := make([]interface{}, 0) - for _, instance := range result.ForwardingRules { - fwdRule := map[string]interface{}{} - fwdRule[pdnsCRFRRuleID] = *instance.ID - fwdRule[pdnsCRFRDesctiption] = *instance.Description - fwdRule[pdnsCRFRType] = *instance.Type - fwdRule[pdnsCRFRMatch] = *instance.Match - fwdRule[pdnsCRFRForwardTo] = instance.ForwardTo - fwdRule[pdnsCRFRViews] = flattenPDNSFRViews(instance.Views) + for _, rule := range result.ForwardingRules { + forwardRule := map[string]interface{}{} + forwardRule[pdnsCRFRRuleID] = *rule.ID + forwardRule[pdnsCRFRDesctiption] = *rule.Description + forwardRule[pdnsCRFRType] = *rule.Type + forwardRule[pdnsCRFRMatch] = *rule.Match + forwardRule[pdnsCRFRForwardTo] = rule.ForwardTo + forwardRule[pdnsCRFRViews] = flattenPDNSFRViews(rule.Views) - forwardRules = append(forwardRules, fwdRule) + forwardRules = append(forwardRules, forwardRule) } d.SetId(dataSourceIBMPrivateDNSForwardrulesID()) d.Set(pdnsInstanceID, instanceID) From f6ddd4e99ee10c6b385958b5e9e23c60dff7d29a Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sun, 20 Oct 2024 00:32:04 +0530 Subject: [PATCH 15/23] changing update logic for views --- ...ate_dns_custom_resolver_forwarding_rule.go | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index fb2f94c55a..44d40e6a7d 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -163,7 +163,6 @@ func resourceIbmDnsCrForwardingRuleCreate(context context.Context, d *schema.Res forwardingRuleInpOnlyRule.Description = &ruleDescription opt.SetForwardingRuleInput(forwardingRuleInpOnlyRule) } - // forward_to not present } else { if _, ok := d.GetOk(pdnsCRFRViews); ok { forwardingRuleInpOnlyView, _ := dnsSvcsClient.NewForwardingRuleInputForwardingRuleOnlyView(ruleType, ruleMatch, expandPDNSFRViews(views)) @@ -231,9 +230,18 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res frdesc := des.(string) opt.SetDescription(frdesc) } - if _, ok := d.GetOk(pdnsCRFRForwardTo); ok { - opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + + // Update logic is changed. Now we can have empty forward_to field if views are present. The only constraint is both the fields should not be empty. + if _, ok := d.GetOk(pdnsCRFRForwardTo); !ok { + if _, ok := d.GetOk(pdnsCRFRViews); !ok { + return diag.FromErr(fmt.Errorf("[ERROR] Cannot update the forwarding rules. One of the fields from forward_to or views must be provided.")) + } } + + // Once we make sure the one of the field from forward_to or views is present we can allow empty fields to be updated. + opt.SetForwardTo(flex.ExpandStringList(d.Get(pdnsCRFRForwardTo).([]interface{}))) + opt.SetViews(expandPDNSFRViews(d.Get(pdnsCRFRViews).([]interface{}))) + if ty, ok := d.GetOk(pdnsCRFRType); ok { crtype := ty.(string) if strings.ToLower(crtype) == "Default" { @@ -243,9 +251,7 @@ func resourceIbmDnsCrForwardingRuleUpdate(context context.Context, d *schema.Res } } } - if view, ok := d.GetOk(pdnsCRFRViews); ok { - opt.SetViews(expandPDNSFRViews(view.([]interface{}))) - } + result, resp, err := dnsSvcsClient.UpdateForwardingRuleWithContext(context, opt) if err != nil || result == nil { return diag.FromErr(fmt.Errorf("[ERROR] Error updating the forwarding rule %s:%s", err, resp)) @@ -273,7 +279,8 @@ func resourceIbmDnsCrForwardingRuleDelete(context context.Context, d *schema.Res return nil } -func expandPDNSFRViews(viewsList []interface{}) (views []dns.ViewConfig) { +func expandPDNSFRViews(viewsList []interface{}) []dns.ViewConfig { + views := []dns.ViewConfig{} for _, viewElem := range viewsList { viewItem := viewElem.(map[string]interface{}) view := dns.ViewConfig{ @@ -284,7 +291,7 @@ func expandPDNSFRViews(viewsList []interface{}) (views []dns.ViewConfig) { } views = append(views, view) } - return + return views } func flattenPDNSFRViews(list []dns.ViewConfig) []map[string]interface{} { From 0335f54a189309ae40d17504ad551c04839197b6 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Tue, 22 Oct 2024 15:15:25 +0530 Subject: [PATCH 16/23] modified test for linked zone --- .../resource_ibm_dns_linked_zone_test.go | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go b/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go index 3bcb9f65cb..d7163b28b1 100644 --- a/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go +++ b/ibm/service/dnsservices/resource_ibm_dns_linked_zone_test.go @@ -17,6 +17,8 @@ import ( func TestAccIBMDNSLinkedZone_basic(t *testing.T) { name := fmt.Sprintf("seczone-cr-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() {}, @@ -24,9 +26,11 @@ func TestAccIBMDNSLinkedZone_basic(t *testing.T) { CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), + resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "owner_instance_id", ownerInstanceId), + resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "owner_zone_id", ownerZoneId), ), }, }, @@ -35,13 +39,15 @@ func TestAccIBMDNSLinkedZone_basic(t *testing.T) { func TestAccIBMDNSLinkedZone_update(t *testing.T) { name := fmt.Sprintf("seczone-cr-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() {}, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), ), @@ -69,25 +75,28 @@ func testAccCheckIBMDNSLinkedZoneUpdateConfig(name string, description string, l plan = "standard" } resource "ibm_dns_linked_zone" "test" { + name = "%s" instance_id = ibm_resource_instance.test-pdns-cr-instance.id owner_instance_id = "OWNER Instance ID" owner_zone_id = "OWNER ZONE ID" - description = "new test CR - TF" - label = "label" + description = "%s" + label = "%s" } - `) + `, name, description, label) } func TestAccIBMDNSLinkedZoneImport(t *testing.T) { var linkedZoneID string name := fmt.Sprintf("seczone-vpc-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) + ownerInstanceId := "OWNER Instance ID" + ownerZoneId := "OWNER ZONE ID" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMDNSLinkedZoneDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMDNSLinkedZoneBasic(name), + Config: testAccCheckIBMDNSLinkedZoneBasic(name, ownerInstanceId, ownerZoneId), Check: resource.ComposeTestCheckFunc( testAccCheckIBMDNSLinkedZoneExists("ibm_dns_linked_zone.test", &linkedZoneID), resource.TestCheckResourceAttr("ibm_dns_linked_zone.test", "name", name), @@ -134,7 +143,7 @@ func testAccCheckIBMDNSLinkedZoneDestroy(s *terraform.State) error { return nil } -func testAccCheckIBMDNSLinkedZoneBasic(name string) string { +func testAccCheckIBMDNSLinkedZoneBasic(name string, ownerInstanceId string, ownerZoneId string) string { return fmt.Sprintf(` resource "ibm_resource_group" "rg" { name = "DNS_linked_zone_test" @@ -149,10 +158,10 @@ func testAccCheckIBMDNSLinkedZoneBasic(name string) string { resource "ibm_dns_linked_zone" "test" { name = "%s" instance_id = ibm_resource_instance.test-pdns-cr-instance.id - owner_instance_id = "OWNER Instance ID" - owner_zone_id = "OWNER ZONE ID" + owner_instance_id = "%s" + owner_zone_id = "%s" } - `, name) + `, name, ownerInstanceId, ownerZoneId) } //func testAccCheckIBMDNSLinkedZoneResource(vpcname, subnetname, zone, cidr, name, description string) string { From 95ecf4d67125b0dbcd95a3c5ccbca1ecd1db81e8 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Tue, 22 Oct 2024 19:35:44 +0530 Subject: [PATCH 17/23] add test for custom resolver profile --- ...resource_ibm_private_dns_custom_resolver_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go index 4fb4d5e6d9..b63f46246a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_test.go @@ -22,17 +22,19 @@ func TestAccIBMPrivateDNSCustomResolver_basic(t *testing.T) { subnetname := fmt.Sprintf("cr-subnet-name-%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("testpdnscustomresolver%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) description := "new test CR - TF" + profile := "essential" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description), + Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description, profile), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPrivateDNSCustomResolverExists("ibm_dns_custom_resolver.test", resultprivatedns), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "name", name), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "description", description), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "profile", profile), ), }, }, @@ -45,16 +47,18 @@ func TestAccIBMPrivateDNSCustomResolverImport(t *testing.T) { subnetname := fmt.Sprintf("cr-subnet-name-%d", acctest.RandIntRange(10, 100)) name := fmt.Sprintf("testpdnscustomresolver%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)) description := "new test CR - TF" + profile := "essential" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description), + Config: testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name, description, profile), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPrivateDNSCustomResolverExists("ibm_dns_custom_resolver.test", resultprivatedns), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "name", name), resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "description", description), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver.test", "profile", profile), ), }, { @@ -68,7 +72,7 @@ func TestAccIBMPrivateDNSCustomResolverImport(t *testing.T) { }) } -func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cidr, name, description string) string { +func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cidr, name, description, profile string) string { return fmt.Sprintf(` data "ibm_resource_group" "rg" { is_default = true @@ -101,8 +105,9 @@ func testAccCheckIBMPrivateDNSCustomResolverBasic(vpcname, subnetname, zone, cid subnet_crn = ibm_is_subnet.test-pdns-cr-subnet1.crn enabled = true } + profile = "%s" } - `, vpcname, subnetname, zone, cidr, name, description) + `, vpcname, subnetname, zone, cidr, name, description, profile) } func testAccCheckIBMPrivateDNSCustomResolverExists(n string, result string) resource.TestCheckFunc { From 4c72d23e164b4fc2e9e8fabf2e5633b379fc9fa7 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Tue, 22 Oct 2024 21:00:05 +0530 Subject: [PATCH 18/23] add test for forwarding rule views --- ...ns_custom_resolver_forwarding_rule_test.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go index e34ab97b2d..dfe2725776 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go @@ -18,23 +18,30 @@ func TestAccIBMPrivateDNSCustomResolverForwardingRule_basic(t *testing.T) { match := "test.example.com" vpcname := fmt.Sprintf("fr-vpc-%d", acctest.RandIntRange(10, 100)) subnetname := fmt.Sprintf("fr-subnet-name-%d", acctest.RandIntRange(10, 100)) + viewName := "view-example-1" + viewDesc := "view-example-description" + viewExpression := "ipInRange(source.ip, '10.240.0.0/24') || ipInRange(source.ip, '10.240.1.0/24')" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, typeVar, match), + Config: testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, typeVar, match, viewName, viewDesc, viewExpression), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "type", typeVar), resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "match", match), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.#", "1"), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.name", viewName), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.description", viewDesc), + resource.TestCheckResourceAttr("ibm_dns_custom_resolver_forwarding_rule.dns_custom_resolver_forwarding_rule", "views.0.expression", viewExpression), ), }, }, }) } -func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, typeVar, match string) string { +func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, typeVar, match, viewName, viewDesc, viewExpression string) string { return fmt.Sprintf(` data "ibm_resource_group" "rg" { is_default = true @@ -75,6 +82,12 @@ func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, t type = "%s" match = "%s" forward_to = ["168.20.22.122"] + views { + name = "%s" + description = "%s" + expression = "%s" + forward_to = ["10.240.2.${count.index}"] + } } - `, vpcname, subnetname, zone, cidr, typeVar, match) + `, vpcname, subnetname, zone, cidr, typeVar, match, viewName, viewDesc, viewExpression) } From 5c37702385b0bfaecad1337aef1d698aa1c9f6f8 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sun, 27 Oct 2024 15:43:31 +0530 Subject: [PATCH 19/23] fix acceptance test FR --- ...urce_ibm_private_dns_custom_resolver_forwarding_rule_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go index dfe2725776..1458e1709a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule_test.go @@ -86,7 +86,7 @@ func testAccCheckIbmDnsCrForwardingRuleConfig(vpcname, subnetname, zone, cidr, t name = "%s" description = "%s" expression = "%s" - forward_to = ["10.240.2.${count.index}"] + forward_to = ["10.240.2.1"] } } `, vpcname, subnetname, zone, cidr, typeVar, match, viewName, viewDesc, viewExpression) From 004b648c39c38e694ffeb0c774f8c7bab6898c72 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Mon, 4 Nov 2024 15:40:41 +0530 Subject: [PATCH 20/23] change message format --- ...source_ibm_private_dns_custom_resolver_forwarding_rules.go | 2 +- .../dnsservices/resource_ibm_private_dns_custom_resolver.go | 2 +- ...esource_ibm_private_dns_custom_resolver_forwarding_rule.go | 2 +- .../docs/d/dns_custom_resolver_forwarding_rules.html.markdown | 4 ++-- website/docs/r/dns_custom_resolver.html.markdown | 4 ++-- .../docs/r/dns_custom_resolver_forwarding_rule.html.markdown | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 54dfc108cd..96e6f3dead 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -85,7 +85,7 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { pdnsCRFRVForwardTo: { Type: schema.TypeList, Required: true, - Description: "The upstream DNS servers will be forwarded to.", + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index b5d2adb00a..e471d12d95 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -205,7 +205,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { pdnsCRFRVForwardTo: { Type: schema.TypeList, Required: true, - Description: "The upstream DNS servers will be forwarded to.", + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to..", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index 44d40e6a7d..b01736c0bd 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -106,7 +106,7 @@ func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { pdnsCRFRVForwardTo: { Type: schema.TypeList, Required: true, - Description: "The upstream DNS servers will be forwarded to.", + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown index d1cabd42d2..5b6b41468b 100644 --- a/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown +++ b/website/docs/d/dns_custom_resolver_forwarding_rules.html.markdown @@ -34,7 +34,7 @@ In addition to the argument references list, you can access the following attrib Nested scheme for `forwarding_rules`: - `description` - (String) Descriptive text of the forwarding rule. - - `forward_to` - (List) List of the upstream DNS that the servers will be forwarded to. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. - `match` - (String) The matching zone or hostname. - `rule_id` - (String) Identifier of the forwarding rule. - `type` - (String) Type of the forwarding rule. @@ -44,4 +44,4 @@ In addition to the argument references list, you can access the following attrib - `name` - (String) Name of the view. - `description` - (String) Description of the view. - `expression` - (String) Expression of the view. - - `forward_to` - (List) List of the upstream DNS that the servers will be forwarded to. + - `forward_to` - (List) List of upstream DNS servers that the matching DNS queries will be forwarded to. diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index ef4da81f05..406e51ad6e 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -100,14 +100,14 @@ In addition to all argument reference list, you can access the following attribu - `type` - (String) Type of the forwarding rule. - Constraints: Allowable values are: `zone`, `hostname`. - `match` - (String) The matching zone or hostname. - - `forward_to` - (List) The upstream DNS servers will be forwarded to. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. - `views` (List) List of views attached to the custom resolver. Nested scheme for `views`: - `name` - (String) Name of the view. - `description` - (String) Description of the view. - `expression` - (String) Expression of the view. - - `forward_to` - (List) List of the upstream DNS servers will be forwarded to. + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to ## Import diff --git a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown index 111f6b8581..4ab8e0f5f0 100644 --- a/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown +++ b/website/docs/r/dns_custom_resolver_forwarding_rule.html.markdown @@ -81,14 +81,14 @@ Review the argument reference that you can specify for your resource. * `type` - (Optional, String) Type of the forwarding rule. * Constraints: Allowable values is: `zone`. * `match` - (Optional, String) The matching zone or hostname. -* `forward_to` - (Optional, List) The upstream DNS servers will be forwarded to. +* `forward_to` - (Optional, List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. * `views` (Optional, List) List of views attached to the custom resolver. Nested scheme for `views`: * `name` - (Required, String) Name of the view. * `description` - (optional, String) Description of the view. * `expression` - (Required, String) Expression of the view. - * `forward_to` - (Required, List) List of the upstream DNS servers will be forwarded to. + * `forward_to` - (Required, List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. ## Attribute reference From 3c9d28454aef8f9fa2e0b2377b3894ddae81a94f Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Tue, 12 Nov 2024 18:45:49 +0530 Subject: [PATCH 21/23] change fields to computed in data source file --- .../data_source_ibm_private_dns_custom_resolver.go | 6 ++---- ...ibm_private_dns_custom_resolver_forwarding_rules.go | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go index 8ca4fe77d4..994c10e570 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver.go @@ -53,14 +53,12 @@ func DataSourceIBMPrivateDNSCustomResolver() *schema.Resource { }, pdnsCRProfile: { Type: schema.TypeString, - Optional: true, - Default: "essential", + Computed: true, Description: "The profile name of the custom resolver.", }, pdnsCRAllowDisruptiveUpdates: { Type: schema.TypeBool, - Optional: true, - Default: false, + Computed: true, Description: "Whether a disruptive update is allowed for the custom resolver", }, pdnsCustomResolverLocations: { diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 96e6f3dead..182e61392b 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -64,27 +64,27 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { pdnsCRFRViews: { Type: schema.TypeList, Description: "An array of views used by forwarding rules", - Optional: true, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ pdnsCRFRVName: { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Unique name of the view.", }, pdnsCRFRVDescription: { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Description of the view.", }, pdnsCRFRVExpression: { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Expression of the view.", }, pdnsCRFRVForwardTo: { Type: schema.TypeList, - Required: true, + Computed: true, Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", Elem: &schema.Schema{Type: schema.TypeString}, }, From 4328e8e190dfd846254b18e6d464171dd8fa8b99 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Mon, 6 Jan 2025 22:21:40 +0530 Subject: [PATCH 22/23] incorporated doc review changes --- ...urce_ibm_private_dns_custom_resolver_forwarding_rules.go | 2 +- .../dnsservices/resource_ibm_private_dns_custom_resolver.go | 6 +++--- ...ource_ibm_private_dns_custom_resolver_forwarding_rule.go | 2 +- website/docs/r/dns_custom_resolver.html.markdown | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go index 182e61392b..032c74e1d2 100644 --- a/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go +++ b/ibm/service/dnsservices/data_source_ibm_private_dns_custom_resolver_forwarding_rules.go @@ -63,7 +63,7 @@ func DataSourceIBMPrivateDNSForwardingRules() *schema.Resource { }, pdnsCRFRViews: { Type: schema.TypeList, - Description: "An array of views used by forwarding rules", + Description: "An array of views used by forwarding rules.", Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go index e471d12d95..8e0a6d5c2a 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver.go @@ -146,7 +146,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - Description: "Whether a disruptive update is allowed for the custom resolver", + Description: "Whether a disruptive update is allowed for the custom resolver.", }, pdnsCRForwardRules: { Type: schema.TypeList, @@ -183,7 +183,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { }, pdnsCRFRViews: { Type: schema.TypeList, - Description: "An array of views used by forwarding rules", + Description: "An array of views used by forwarding rules.", Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -205,7 +205,7 @@ func ResourceIBMPrivateDNSCustomResolver() *schema.Resource { pdnsCRFRVForwardTo: { Type: schema.TypeList, Required: true, - Description: "The upstream DNS servers that the matching DNS queries will be forwarded to..", + Description: "The upstream DNS servers that the matching DNS queries will be forwarded to.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go index b01736c0bd..8426dfca04 100644 --- a/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go +++ b/ibm/service/dnsservices/resource_ibm_private_dns_custom_resolver_forwarding_rule.go @@ -84,7 +84,7 @@ func ResourceIBMPrivateDNSForwardingRule() *schema.Resource { }, pdnsCRFRViews: { Type: schema.TypeList, - Description: "An array of views used by forwarding rules", + Description: "An array of views used by forwarding rules.", Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/website/docs/r/dns_custom_resolver.html.markdown b/website/docs/r/dns_custom_resolver.html.markdown index 406e51ad6e..baa3900f2a 100644 --- a/website/docs/r/dns_custom_resolver.html.markdown +++ b/website/docs/r/dns_custom_resolver.html.markdown @@ -107,7 +107,7 @@ In addition to all argument reference list, you can access the following attribu - `name` - (String) Name of the view. - `description` - (String) Description of the view. - `expression` - (String) Expression of the view. - - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to + - `forward_to` - (List) List of the upstream DNS servers that the matching DNS queries will be forwarded to. ## Import From 35658387becf3aa6317305acf1bac5bbf4c095cc Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Sat, 11 Jan 2025 07:44:14 +0530 Subject: [PATCH 23/23] fix go mod issues --- go.mod | 22 +++++++++++----------- go.sum | 36 ++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 700e08984b..030092c5ff 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/IBM-Cloud/terraform-provider-ibm -go 1.22.5 +go 1.23.3 -toolchain go1.23.2 +toolchain go1.23.4 require ( github.com/IBM-Cloud/bluemix-go v0.0.0-20241117121028-a3be206688b3 @@ -22,7 +22,7 @@ require ( github.com/IBM/eventstreams-go-sdk v1.4.0 github.com/IBM/go-sdk-core v1.1.0 github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/go-sdk-core/v5 v5.18.3 + github.com/IBM/go-sdk-core/v5 v5.18.5 github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1 github.com/IBM/ibm-cos-sdk-go v1.12.0 github.com/IBM/ibm-cos-sdk-go-config/v2 v2.2.0 @@ -32,7 +32,7 @@ require ( github.com/IBM/logs-go-sdk v0.4.0 github.com/IBM/logs-router-go-sdk v1.0.5 github.com/IBM/mqcloud-go-sdk v0.2.0 - github.com/IBM/networking-go-sdk v0.49.0 + github.com/IBM/networking-go-sdk v0.50.0 github.com/IBM/platform-services-go-sdk v0.71.1 github.com/IBM/project-go-sdk v0.3.5 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 @@ -65,7 +65,7 @@ require ( github.com/rook/rook/pkg/apis v0.0.0-20231204200402-5287527732f7 github.com/softlayer/softlayer-go v1.0.3 github.com/stretchr/testify v1.10.0 - golang.org/x/crypto v0.31.0 + golang.org/x/crypto v0.32.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible k8s.io/api v0.31.1 @@ -101,7 +101,7 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.5 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -117,7 +117,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.1 // indirect + github.com/go-playground/validator/v10 v10.23.0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -200,7 +200,7 @@ require ( github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/zclconf/go-cty v1.15.0 // indirect - go.mongodb.org/mongo-driver v1.16.1 // indirect + go.mongodb.org/mongo-driver v1.17.2 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect @@ -208,11 +208,11 @@ require ( go.uber.org/ratelimit v0.2.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.26.0 // indirect diff --git a/go.sum b/go.sum index a592622189..5e5edaddf4 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,8 @@ github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3bt github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns= -github.com/IBM/go-sdk-core/v5 v5.18.3 h1:q6IDU3N2bHGwijK9pMnzKC5gqdaRII56NzB4ZNdSFvY= -github.com/IBM/go-sdk-core/v5 v5.18.3/go.mod h1:5kILxqEWOrwMhoD2b7J6Xv9Z2M6YIdT/6Oy+XRSsCGQ= +github.com/IBM/go-sdk-core/v5 v5.18.5 h1:g0JRl3sYXJczB/yuDlrN6x22LJ6jIxhp0Sa4ARNW60c= +github.com/IBM/go-sdk-core/v5 v5.18.5/go.mod h1:KonTFRR+8ZSgw5cxBSYo6E4WZoY1+7n1kfHM82VcjFU= github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1 h1:JSdt2WuiRCSKok+Jvv+x0eQP6duR1dUg6utKH0bI734= github.com/IBM/ibm-backup-recovery-sdk-go v1.0.1/go.mod h1:ezUFoHQn8MvZI5vNd3H/ds4BCDYOXDodGFrTUgsU33k= github.com/IBM/ibm-cos-sdk-go v1.12.0 h1:Wrk3ve4JS3euhl7XjNFd3RlvPT56199G2/rKaPWpRKU= @@ -154,8 +154,8 @@ github.com/IBM/logs-router-go-sdk v1.0.5 h1:r0kC1+HfmSeQCD6zQTUp4PDI/zp4Ueo1Zo19 github.com/IBM/logs-router-go-sdk v1.0.5/go.mod h1:tCN2vFgu5xG0ob9iJcxi5M4bJ6mWmu3nhmRPnvlwev0= github.com/IBM/mqcloud-go-sdk v0.2.0 h1:QOWk8ZGk0QfIL0MOGTKzNdM3Qe0Hk+ifAFtNSFQo5HU= github.com/IBM/mqcloud-go-sdk v0.2.0/go.mod h1:VZQKMtqmcdXKhmLhLiPuS/UHMs/5yo2tA/nD83cQt9E= -github.com/IBM/networking-go-sdk v0.49.0 h1:lPS34u3C0JVrbxH+Ulua76Nwl6Frv8BEfq6LRkyvOv0= -github.com/IBM/networking-go-sdk v0.49.0/go.mod h1:G9CKbmPE8gSLjN+ABh4hIZ1bMx076enl5Eekvj6zQnA= +github.com/IBM/networking-go-sdk v0.50.0 h1:3BHO1GrFnkkZ4mYyn2nQc+Djw48/g3znJe3k4a4p1Yk= +github.com/IBM/networking-go-sdk v0.50.0/go.mod h1:aDKmbdfJG+JnoV9RvxOPg7nmgTKReyBgX8aAZHolcm8= github.com/IBM/platform-services-go-sdk v0.71.1 h1:EyqSctlLVqj092yU6K9hyTyx7JIpzhE192n6eG+Daac= github.com/IBM/platform-services-go-sdk v0.71.1/go.mod h1:ApFkvqw7NaluWJ5Uq+afdM/2jQqo5ILc0SzKSVobYNw= github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM= @@ -368,8 +368,8 @@ github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8 github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= -github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -500,8 +500,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= -github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o= +github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -1268,8 +1268,8 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= -go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8= -go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw= +go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM= +go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1341,8 +1341,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1472,8 +1472,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1636,8 +1636,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1658,8 +1658,8 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=