maintenance/aws-janitor/resources/clean.go
func CleanAll(sess *session.Session, region string) error {
	acct, err := account.GetAccount(sess, regions.Default)
	if err != nil {
		return errors.Wrap(err, "Failed to retrieve account")
	}
	klog.V(1).Infof("Account: %s", acct)

	var regionList []string
	if region == "" {
		regionList, err = regions.GetAll(sess)
		if err != nil {
			return errors.Wrap(err, "Couldn't retrieve list of regions")
		}
	} else {
		regionList = []string{region}
	}
	klog.Infof("Regions: %+v", regionList)

	for _, r := range regionList {
		for _, typ := range RegionalTypeList {
			set, err := typ.ListAll(sess, acct, r)
			if err != nil {
				return errors.Wrapf(err, "Failed to list resources of type %T", typ)
			}
			if err := typ.MarkAndSweep(sess, acct, r, set); err != nil {
				return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ)
			}
		}
	}

	for _, typ := range GlobalTypeList {
		set, err := typ.ListAll(sess, acct, regions.Default)
		if err != nil {
			return errors.Wrapf(err, "Failed to list resources of type %T", typ)
		}
		if err := typ.MarkAndSweep(sess, acct, regions.Default, set); err != nil {
			return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ)
		}
	}

	return nil
}
func CleanAll(sess *session.Session, region string) error {
	acct, err := account.GetAccount(sess, regions.Default)
	if err != nil {
		return errors.Wrap(err, "Failed to retrieve account")
	}
	klog.V(1).Infof("Account: %s", acct)

	var regionList []string
	if region == "" {
		regionList, err = regions.GetAll(sess)
		if err != nil {
			return errors.Wrap(err, "Couldn't retrieve list of regions")
		}
	} else {
		regionList = []string{region}
	}
	klog.Infof("Regions: %+v", regionList)

	for _, r := range regionList {
		for _, typ := range RegionalTypeList {
			set, err := typ.ListAll(sess, acct, r)
			if err != nil {
				return errors.Wrapf(err, "Failed to list resources of type %T", typ)
			}
			if err := typ.MarkAndSweep(sess, acct, r, set); err != nil {
				return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ)
			}
		}
	}

	for _, typ := range GlobalTypeList {
		set, err := typ.ListAll(sess, acct, regions.Default)
		if err != nil {
			return errors.Wrapf(err, "Failed to list resources of type %T", typ)
		}
		if err := typ.MarkAndSweep(sess, acct, regions.Default, set); err != nil {
			return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ)
		}
	}

	return nil
}
// CleanAll cleans all of the resources for all of the regions visible to
// the provided AWS session.