From 1413d032ee003c98adb7586b5ac51f9f129da789 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Mon, 16 Nov 2015 16:58:11 -0600 Subject: [PATCH] provider/aws: Fix crash in Route53 Record if Zone not found --- builtin/providers/aws/resource_aws_route53_record.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builtin/providers/aws/resource_aws_route53_record.go b/builtin/providers/aws/resource_aws_route53_record.go index a5b9ef468..cf99b9b9b 100644 --- a/builtin/providers/aws/resource_aws_route53_record.go +++ b/builtin/providers/aws/resource_aws_route53_record.go @@ -49,6 +49,13 @@ func resourceAwsRoute53Record() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, + ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + value := v.(string) + if value == "" { + es = append(es, fmt.Errorf("Cannot have empty zone_id")) + } + return + }, }, "ttl": &schema.Schema{ @@ -136,6 +143,9 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er if err != nil { return err } + if zoneRecord.HostedZone == nil { + return fmt.Errorf("[WARN] No Route53 Zone found for id (%s)", zone) + } // Get the record rec, err := resourceAwsRoute53RecordBuildSet(d, *zoneRecord.HostedZone.Name)