func (rd *AutoScalingLaunchConfigurationDeleter) DeleteResources(cfg *DeleteConfig) error {
	if len(rd.ResourceNames) == 0 {
		return nil
	}
	fmtStr := "Deleted LaunchConfiguration"
	var params *autoscaling.DeleteLaunchConfigurationInput
	for _, n := range rd.ResourceNames {
		if cfg.DryRun {
			fmt.Println(drStr, fmtStr, n)
			continue
		}
		params = &autoscaling.DeleteLaunchConfigurationInput{
			LaunchConfigurationName: n.AWSString(),
		}
		ctx := aws.BackgroundContext()
		_, err := rd.GetClient().DeleteLaunchConfigurationWithContext(ctx, params)
		if err != nil {
			cfg.logRequestError(arn.AutoScalingLaunchConfigurationRType, n, err)
			if cfg.IgnoreErrors {
				continue
			}
			return err
		}
		cfg.logRequestSuccess(arn.AutoScalingLaunchConfigurationRType, n)
		fmt.Println(fmtStr, n)
	}
	return nil
}
DeleteResources deletes a launch configurations from AWS
package deleter
import (
	"fmt"
	"strings"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/service/autoscaling"
	"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
	"github.com/aws/aws-sdk-go/service/iam"
	"github.com/coreos/grafiti/arn"
)
func isValidationError(err error) bool {
	aerr, ok := err.(awserr.Error)
	return ok && aerr.Code() == ErrCodeValidationError
}
type AutoScalingGroupDeleter struct {
	Client        autoscalingiface.AutoScalingAPI
	ResourceType  arn.ResourceType
	ResourceNames arn.ResourceNames
}
func (rd *AutoScalingGroupDeleter) String() string {
	return fmt.Sprintf(`{"Type": "%s", "Names": %v}`, rd.ResourceType, rd.ResourceNames)
}
func (rd *AutoScalingGroupDeleter) GetClient() autoscalingiface.AutoScalingAPI {
	if rd.Client == nil {
		rd.Client = autoscaling.New(setUpAWSSession())
	}
	return rd.Client
}
func (rd *AutoScalingGroupDeleter) AddResourceNames(ns ...arn.ResourceName) {
	rd.ResourceNames = append(rd.ResourceNames, ns...)
}
func (rd *AutoScalingGroupDeleter) DeleteResources(cfg *DeleteConfig) error {
	if len(rd.ResourceNames) == 0 {
		return nil
	}
	fmtStr := "Deleted AutoScalingGroup"
	var params *autoscaling.DeleteAutoScalingGroupInput
	for _, n := range rd.ResourceNames {
		if cfg.DryRun {
			fmt.Println(drStr, fmtStr, n)
			continue
		}
		params = &autoscaling.DeleteAutoScalingGroupInput{
			AutoScalingGroupName: n.AWSString(),
			ForceDelete:          aws.Bool(true),
		}
		ctx := aws.BackgroundContext()
		_, err := rd.GetClient().DeleteAutoScalingGroupWithContext(ctx, params)
		if err != nil {
			cfg.logRequestError(arn.AutoScalingGroupRType, n, err)
			if cfg.IgnoreErrors {
				continue
			}
			return err
		}
		cfg.logRequestSuccess(arn.AutoScalingGroupRType, n)
		fmt.Println(fmtStr, n)
	}
	return nil
}
func (rd *AutoScalingGroupDeleter) RequestAutoScalingGroups() ([]*autoscaling.Group, error) {
	if len(rd.ResourceNames) == 0 {
		return nil, nil
	}
	var lcs []*autoscaling.Group
	for _, name := range rd.ResourceNames {
		var err error
		if lcs, err = rd.requestAutoScalingGroup(name, lcs); err != nil && !isValidationError(err) {
			return lcs, err
		}
	}
	return lcs, nil
}
func (rd *AutoScalingGroupDeleter) requestAutoScalingGroup(rn arn.ResourceName, lcs []*autoscaling.Group) ([]*autoscaling.Group, error) {
	params := &autoscaling.DescribeAutoScalingGroupsInput{
		AutoScalingGroupNames: []*string{rn.AWSString()},
	}
	ctx := aws.BackgroundContext()
	resp, err := rd.GetClient().DescribeAutoScalingGroupsWithContext(ctx, params)
	if err != nil {
		fmt.Printf("{\"error\": \"%s\"}\n", err)
		return lcs, err
	}
	lcs = append(lcs, resp.AutoScalingGroups...)
	return lcs, nil
}
type AutoScalingLaunchConfigurationDeleter struct {
	Client        autoscalingiface.AutoScalingAPI
	ResourceType  arn.ResourceType
	ResourceNames arn.ResourceNames
}
func (rd *AutoScalingLaunchConfigurationDeleter) String() string {
	return fmt.Sprintf(`{"Type": "%s", "Names": %v}`, rd.ResourceType, rd.ResourceNames)
}
func (rd *AutoScalingLaunchConfigurationDeleter) GetClient() autoscalingiface.AutoScalingAPI {
	if rd.Client == nil {
		rd.Client = autoscaling.New(setUpAWSSession())
	}
	return rd.Client
}
func (rd *AutoScalingLaunchConfigurationDeleter) AddResourceNames(ns ...arn.ResourceName) {
	rd.ResourceNames = append(rd.ResourceNames, ns...)
}