func (es *ECSService) ServicePreviousVersion(serviceName, clusterName string) (string, error) {
	taskARN, err := es.getCurrentTask(serviceName, clusterName)
	if err != nil {
		return "", fmt.Errorf(awsApisErrorFmt, err)
	}
	tt := strings.Split(taskARN, ":")
	currentVersionStr := tt[len(tt)-1]
	currentVersion, err := strconv.Atoi(currentVersionStr)
	if err != nil {
		return "", err
	}
	previousVersion := currentVersion - 1
	if previousVersion <= 0 {
		return "", fmt.Errorf("impossible to rollback to version %d", previousVersion)
	}
	previousVersionStr := strconv.Itoa(previousVersion)
	return strings.Join(append(tt[:len(tt)-1], previousVersionStr), ":"), nil
}
ServicePreviousVersion returns previous task version as ARN string.
package aws
import (
	"fmt"
	"net/http"
	"os"
	"strconv"
	"strings"
	"time"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/ecs"
)
const awsApisErrorFmt = "error on AWS request: %s"
type ServiceInfo struct {
	ARN     string
	TaskARN string
}
type ECSService struct {
	verbose bool
	client  *ecs.ECS
}