Example #1
0
// DescribeCluster will return a Cluster (detail struct)
func DescribeCluster(svc *ecs.ECS, cluster *string) (*ecs.Cluster, error) {
	// Get cluster details for all the things...
	reqParams := &ecs.DescribeClustersInput{
		Clusters: []*string{cluster},
	}

	resp, err := svc.DescribeClusters(reqParams)

	if err != nil {
		return nil, fmt.Errorf("ecs.DescribeClusters: %s", err.Error())
	}

	return resp.Clusters[0], err
}
Example #2
0
// Verify that the ECS cluster exists.
func VerifyClusterExists(ecs_obj *ecs.ECS, cluster string) error {
	params := &ecs.DescribeClustersInput{
		Clusters: []*string{
			aws.String(cluster),
		},
	}
	clusters, err := ecs_obj.DescribeClusters(params)

	if err != nil {
		return fmt.Errorf("Cannot verify if ECS cluster exists: %s", FormatAwsError(err))
	}
	if len(clusters.Clusters) == 0 {
		return fmt.Errorf("Error: ECS Cluster '%s' does not exist, cannot proceed.\n", cluster)
	}
	if len(clusters.Clusters) != 1 {
		return fmt.Errorf("Error: Unexpected number of ECS Clusters returned when searching for '%s'. Received: %+v\n", cluster, clusters.Clusters)
	}
	return nil
}