Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/spot_instances_request: Fix failing acceptance test (SubnetId) #2054

Merged
merged 1 commit into from
Oct 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions aws/resource_aws_spot_instance_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ func testAccCheckAWSSpotInstanceRequest_InstanceAttributes(
func testAccCheckAWSSpotInstanceRequest_NetworkInterfaceAttributes(
sir *ec2.SpotInstanceRequest) resource.TestCheckFunc {
return func(s *terraform.State) error {

if sir.LaunchSpecification.NetworkInterfaces == nil || len(sir.LaunchSpecification.NetworkInterfaces) != 1 {
return fmt.Errorf("Error with Spot Instance Network Interface count")
nis := sir.LaunchSpecification.NetworkInterfaces
if nis == nil || len(nis) != 1 {
return fmt.Errorf("Expected exactly 1 network interface, found %d", len(nis))
}

return nil
Expand All @@ -354,8 +354,15 @@ func testAccCheckAWSSpotInstanceRequest_NetworkInterfaceAttributes(
func testAccCheckAWSSpotInstanceRequestAttributesVPC(
sir *ec2.SpotInstanceRequest) resource.TestCheckFunc {
return func(s *terraform.State) error {
if sir.LaunchSpecification.SubnetId == nil {
return fmt.Errorf("SubnetID was not passed, but should have been for this instance to belong to a VPC")
nis := sir.LaunchSpecification.NetworkInterfaces
if nis == nil || len(nis) != 1 {
return fmt.Errorf("Expected exactly 1 network interface, found %d", len(nis))
}

ni := nis[0]

if ni.SubnetId == nil {
return fmt.Errorf("Expected SubnetId not be non-empty for %s as the instance belongs to a VPC", *sir.InstanceId)
}
return nil
}
Expand Down