func ImportImageRefreshFunc(conn *ec2.EC2, importTaskId string) StateRefreshFunc { return func() (interface{}, string, error) { resp, err := conn.DescribeImportImageTasks(&ec2.DescribeImportImageTasksInput{ ImportTaskIds: []*string{ &importTaskId, }, }, ) if err != nil { if ec2err, ok := err.(awserr.Error); ok && strings.HasPrefix(ec2err.Code(), "InvalidConversionTaskId") { resp = nil } else if isTransientNetworkError(err) { resp = nil } else { log.Printf("Error on ImportImageRefresh: %s", err) return nil, "", err } } if resp == nil || len(resp.ImportImageTasks) == 0 { return nil, "", nil } i := resp.ImportImageTasks[0] return i, *i.Status, nil } }