From 8f70920c1729fd5028550281280680403e435827 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 22 Aug 2014 12:20:06 -0700 Subject: [PATCH] providers/aws: fix some other issues with aws_instance --- builtin/providers/aws/resource_aws_instance.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 8cf300bdc..d911ad975 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -60,8 +60,9 @@ func resourceAwsInstance() *schema.Resource { "key_name": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, + Computed: true, }, "subnet_id": &schema.Schema{ @@ -147,7 +148,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error { } if v := d.Get("security_groups"); v != nil { - for _, v := range v.([]interface{}) { + for _, v := range v.(*schema.Set).List() { str := v.(string) var g ec2.SecurityGroup @@ -320,7 +321,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error { useID := instance.SubnetId != "" if v := d.Get("security_groups"); v != nil { match := false - for _, v := range v.([]interface{}) { + for _, v := range v.(*schema.Set).List() { if strings.HasPrefix(v.(string), "sg-") { match = true break