func vpnConnectionRefreshFunc(conn *ec2.EC2, connectionId string) resource.StateRefreshFunc { return func() (interface{}, string, error) { resp, err := conn.DescribeVPNConnections(&ec2.DescribeVPNConnectionsInput{ VPNConnectionIDs: []*string{aws.String(connectionId)}, }) if err != nil { if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidVpnConnectionID.NotFound" { resp = nil } else { log.Printf("Error on VPNConnectionRefresh: %s", err) return nil, "", err } } if resp == nil || len(resp.VPNConnections) == 0 { return nil, "", nil } connection := resp.VPNConnections[0] return connection, *connection.State, nil } }