From 9fc6c27de14d1ae4c27d19bcd57910d636385e16 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 8 Dec 2015 14:22:51 -0600 Subject: [PATCH] provider/aws: Check for empty instances in AWS Instance RunInstance response Fixes #4206 --- builtin/providers/aws/resource_aws_instance.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index d096a45d6..f9f2a29d7 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -370,6 +370,9 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error { if err != nil { return fmt.Errorf("Error launching source instance: %s", err) } + if runResp == nil || len(runResp.Instances) == 0 { + return fmt.Errorf("Error launching source instance: no instances returned in response") + } instance := runResp.Instances[0] log.Printf("[INFO] Instance ID: %s", *instance.InstanceId)