From 751140351b3747d5652479f2632b4c9b5e9b7175 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Wed, 11 Mar 2015 09:55:32 -0500 Subject: [PATCH] code cleanup on subnet check --- builtin/providers/aws/resource_aws_instance.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index b732f8e8ca..5475e74540 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -287,15 +287,12 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error { associatePublicIPAddress = v.(bool) } - // check for non-default Subnet - subnet := false - var subnetID string - if v, ok := d.GetOk("subnet_id"); ok { - subnet = true - subnetID = v.(string) - } + // check for non-default Subnet, and cast it to a String + var hasSubnet bool + subnet, hasSubnet := d.GetOk("subnet_id") + subnetID := subnet.(string) - if subnet && associatePublicIPAddress { + if hasSubnet && associatePublicIPAddress { // If we have a non-default VPC / Subnet specified, we can flag // AssociatePublicIpAddress to get a Public IP assigned. By default these are not provided. // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise