code cleanup on subnet check

This commit is contained in:
Clint Shryock 2015-03-11 09:55:32 -05:00
parent 9d6f05e529
commit 751140351b
1 changed files with 5 additions and 8 deletions

View File

@ -287,15 +287,12 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
associatePublicIPAddress = v.(bool) associatePublicIPAddress = v.(bool)
} }
// check for non-default Subnet // check for non-default Subnet, and cast it to a String
subnet := false var hasSubnet bool
var subnetID string subnet, hasSubnet := d.GetOk("subnet_id")
if v, ok := d.GetOk("subnet_id"); ok { subnetID := subnet.(string)
subnet = true
subnetID = v.(string)
}
if subnet && associatePublicIPAddress { if hasSubnet && associatePublicIPAddress {
// If we have a non-default VPC / Subnet specified, we can flag // 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. // 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 // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise