Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vpc): dns update fix on resolver system to delegated #5937

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion ibm/service/vpc/resource_ibm_is_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1336,10 +1336,30 @@ func vpcUpdate(d *schema.ResourceData, meta interface{}, id, name string, hasCha

}
if d.HasChange("dns.0.resolver.0.type") {
_, newResolverType := d.GetChange("dns.0.resolver.0.type")
oldResolverType, newResolverType := d.GetChange("dns.0.resolver.0.type")
if newResolverType != nil && newResolverType.(string) != "" {
ResolverModel.Type = core.StringPtr(newResolverType.(string))
}
if oldResolverType != nil && newResolverType != nil && oldResolverType.(string) != "" && newResolverType.(string) != "" {
if oldResolverType.(string) == "system" && newResolverType.(string) == "delegated" {
vpcId := d.Get("dns.0.resolver.0.vpc_id").(string)
createDnsBindings := &vpcv1.CreateVPCDnsResolutionBindingOptions{
VPCID: core.StringPtr(d.Id()),
VPC: &vpcv1.VPCIdentity{
ID: &vpcId,
},
}
if bindingNameOk, ok := d.GetOk("dns.0.resolver.0.dns_binding_name"); ok {
bindingName := bindingNameOk.(string)
createDnsBindings.Name = &bindingName
}
_, response, err := sess.CreateVPCDnsResolutionBinding(createDnsBindings)
if err != nil {
log.Printf("[DEBUG] CreateVPCDnsResolutionBindingWithContext failed %s\n%s", err, response)
return fmt.Errorf("[ERROR] CreateVPCDnsResolutionBinding failed in vpc update resource %s\n%s", err, response)
}
}
}
}
if d.HasChange("dns.0.resolver.0.vpc_id") {
_, newResolverVpc := d.GetChange("dns.0.resolver.0.vpc_id")
Expand Down
Loading