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

provider/aws Fix import errors when aws_route has VPC endpoint #8445

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion builtin/providers/aws/import_aws_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ func resourceAwsRouteTableImportState(
// Minimal data for route
d := subResource.Data(nil)
d.SetType("aws_route")
d.Set("route_table_id", id)
d.Set("destination_cidr_block", route.DestinationCidrBlock)
d.Set("destination_prefix_list_id", route.DestinationPrefixListId)
d.SetId(routeIDHash(d, route))
d.Set("route_table_id", id)
results = append(results, d)
}
}
Expand Down
6 changes: 5 additions & 1 deletion builtin/providers/aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ func resourceAwsRouteExists(d *schema.ResourceData, meta interface{}) (bool, err

// Create an ID for a route
func routeIDHash(d *schema.ResourceData, r *ec2.Route) string {
return fmt.Sprintf("r-%s%d", d.Get("route_table_id").(string), hashcode.String(*r.DestinationCidrBlock))
dest := r.DestinationCidrBlock
if dest == nil {
dest = r.DestinationPrefixListId
}
return fmt.Sprintf("r-%s%d", d.Get("route_table_id").(string), hashcode.String(*dest))
}

// Helper: retrieve a route
Expand Down