Skip to content

Commit

Permalink
Normalize 'not found' resource log lines on read.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Jan 19, 2018
1 parent 1cc2c5c commit 9ae96bf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aws/data_source_aws_vpc_endpoint_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func dataSourceAwsVpcEndpointServiceRead(d *schema.ResourceData, meta interface{
ServiceNames: aws.StringSlice([]string{serviceName}),
}

log.Printf("[DEBUG] Reading VPC Endpoint Service: %s", req)
log.Printf("[DEBUG] Reading VPC Endpoint Services: %s", req)
resp, err := conn.DescribeVpcEndpointServices(req)
if err != nil {
return fmt.Errorf("Error fetching VPC Endpoint Services: %s", err)
Expand Down
3 changes: 2 additions & 1 deletion aws/resource_aws_vpc_endpoint_route_table_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func resourceAwsVpcEndpointRouteTableAssociationRead(d *schema.ResourceData, met
vpce, err := findResourceVpcEndpoint(conn, endpointId)
if err != nil {
if isAWSErr(err, "InvalidVpcEndpointId.NotFound", "") {
log.Printf("[WARN] VPC Endpoint (%s) not found, removing VPC Endpoint/Route Table association (%s) from state", endpointId, d.Id())
d.SetId("")
return nil
}
Expand All @@ -83,7 +84,7 @@ func resourceAwsVpcEndpointRouteTableAssociationRead(d *schema.ResourceData, met
}
}
if !found {
// The association no longer exists.
log.Printf("[WARN] VPC Endpoint/Route Table association (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion aws/resource_aws_vpc_endpoint_service_allowed_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -63,6 +64,7 @@ func resourceAwsVpcEndpointServiceAllowedPrincipalRead(d *schema.ResourceData, m
principals, err := findResourceVpcEndpointServiceAllowedPrincipals(conn, svcId)
if err != nil {
if isAWSErr(err, "InvalidVpcEndpointServiceId.NotFound", "") {
log.Printf("[WARN]VPC Endpoint Service (%s) not found, removing VPC Endpoint Service allowed principal (%s) from state", svcId, d.Id())
d.SetId("")
return nil
}
Expand All @@ -78,7 +80,7 @@ func resourceAwsVpcEndpointServiceAllowedPrincipalRead(d *schema.ResourceData, m
}
}
if !found {
// The allowed principal no longer exists.
log.Printf("[WARN] VPC Endpoint Service allowed principal (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion aws/resource_aws_vpc_endpoint_subnet_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func resourceAwsVpcEndpointSubnetAssociationRead(d *schema.ResourceData, meta in
vpce, err := findResourceVpcEndpoint(conn, endpointId)
if err != nil {
if isAWSErr(err, "InvalidVpcEndpointId.NotFound", "") {
log.Printf("[WARN] Vpc Endpoint (%s) not found, removing Vpc Endpoint/Subnet association (%s) from state", endpointId, d.Id())
d.SetId("")
return nil
}
Expand All @@ -83,7 +84,7 @@ func resourceAwsVpcEndpointSubnetAssociationRead(d *schema.ResourceData, meta in
}
}
if !found {
// The association no longer exists.
log.Printf("[WARN] Vpc Endpoint/Subnet association (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
Expand Down

0 comments on commit 9ae96bf

Please sign in to comment.