func listKopsInstanceGroups() chan KOPSResult {
	log.Infoln("Listing KOPS instance groups from AWS S3.")
	listChan := make(chan KOPSResult)
	go func() {
		defer close(listChan)
		kopsResult := KOPSResult{}
		awsS3 := s3.New(awsSess, &aws.Config{Region: aws.String(awsRegion)})
		if awsS3 == nil {
			err := fmt.Errorf("nil S3 session: %v", awsS3)
			kopsResult.Err = err
			listChan <- kopsResult
			return
		}
		objects, err := getObjects(awsS3)
		if err != nil {
			kopsResult.Err = err
			listChan <- kopsResult
			return
		}
		igs, err := getObjectContents(awsS3, objects)
		if err != nil {
			kopsResult.Err = err
			listChan <- kopsResult
			return
		}
		log.Infoln("Found", len(igs), "instance groups.")
		kopsResult.InstanceGroups = igs
		listChan <- kopsResult
		return
	}()
	return listChan
}
listKopsInstanceGroups lists instance groups used by kops (stored in S3).
package main
import (
	"fmt"
	"io/ioutil"
	"regexp"
	"strings"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/s3"
	log "github.com/sirupsen/logrus"
	"k8s.io/kops/pkg/apis/kops"
)
type KOPSResult struct {
	InstanceGroups []*kops.InstanceGroup
	Err            error
}