provider/aws: Guard against panic in aws_vpc_endpoint_association (#11613)
I believe that if no VPC Endpoints were returned from the AWS API, we were not guarding against a panic. We were strill trying to inspect the RouteTableIds. This commit will ensure that no errors are thrown before trying to use the RouteTableIds ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSVpcEndpointRouteTableAssociation_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/01 18:06:29 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSVpcEndpointRouteTableAssociation_ -timeout 120m === RUN TestAccAWSVpcEndpointRouteTableAssociation_basic --- PASS: TestAccAWSVpcEndpointRouteTableAssociation_basic (42.83s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 42.859s ```
This commit is contained in:
parent
9c1775a28c
commit
851cc46548
|
@ -72,9 +72,13 @@ func resourceAwsVPCEndpointRouteTableAssociationRead(d *schema.ResourceData, met
|
|||
rtId := d.Get("route_table_id").(string)
|
||||
|
||||
vpce, err := findResourceVPCEndpoint(conn, endpointId)
|
||||
if err, ok := err.(awserr.Error); ok && err.Code() == "InvalidVpcEndpointId.NotFound" {
|
||||
d.SetId("")
|
||||
return nil
|
||||
if err != nil {
|
||||
if err, ok := err.(awserr.Error); ok && err.Code() == "InvalidVpcEndpointId.NotFound" {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
found := false
|
||||
|
@ -143,6 +147,10 @@ func findResourceVPCEndpoint(conn *ec2.EC2, id string) (*ec2.VpcEndpoint, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if output.VpcEndpoints == nil {
|
||||
return nil, fmt.Errorf("No VPC Endpoints were found for %q", id)
|
||||
}
|
||||
|
||||
return output.VpcEndpoints[0], nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue