agent/ec2/ec2_client.go
func (c *ClientImpl) DescribeECSTagsForInstance(instanceID string) ([]*ecs.Tag, error) {
	describeTagsInput := ec2sdk.DescribeTagsInput{
		Filters: []*ec2sdk.Filter{
			{
				Name:   aws.String(ResourceIDFilterName),
				Values: []*string{aws.String(instanceID)},
			},
			{
				Name:   aws.String(ResourceTypeFilterName),
				Values: []*string{aws.String(ResourceTypeFilterValueInstance)},
			},
		},
		MaxResults: aws.Int64(InstanceMaxTagsNum),
	}
	res, err := c.client.DescribeTags(&describeTagsInput)

	if err != nil {
		seelog.Criticalf("Error calling DescribeTags API: %v", err)
		return nil, err
	}

	var tags []*ecs.Tag
	// Convert ec2 tags to ecs tags
	for _, ec2Tag := range res.Tags {
		// Filter out all tags "aws:" prefix
		if !strings.HasPrefix(strings.ToLower(aws.StringValue(ec2Tag.Key)), awsTagPrefix) &&
			!strings.HasPrefix(strings.ToLower(aws.StringValue(ec2Tag.Value)), awsTagPrefix) {
			tags = append(tags, &ecs.Tag{
				Key:   ec2Tag.Key,
				Value: ec2Tag.Value,
			})
		}
	}
	return tags, nil
}
func (c *ClientImpl) DescribeECSTagsForInstance(instanceID string) ([]*ecs.Tag, error) {
	describeTagsInput := ec2sdk.DescribeTagsInput{
		Filters: []*ec2sdk.Filter{
			{
				Name:   aws.String(ResourceIDFilterName),
				Values: []*string{aws.String(instanceID)},
			},
			{
				Name:   aws.String(ResourceTypeFilterName),
				Values: []*string{aws.String(ResourceTypeFilterValueInstance)},
			},
		},
		MaxResults: aws.Int64(InstanceMaxTagsNum),
	}
	res, err := c.client.DescribeTags(&describeTagsInput)

	if err != nil {
		seelog.Criticalf("Error calling DescribeTags API: %v", err)
		return nil, err
	}

	var tags []*ecs.Tag
	// Convert ec2 tags to ecs tags
	for _, ec2Tag := range res.Tags {
		// Filter out all tags "aws:" prefix
		if !strings.HasPrefix(strings.ToLower(aws.StringValue(ec2Tag.Key)), awsTagPrefix) &&
			!strings.HasPrefix(strings.ToLower(aws.StringValue(ec2Tag.Value)), awsTagPrefix) {
			tags = append(tags, &ecs.Tag{
				Key:   ec2Tag.Key,
				Value: ec2Tag.Value,
			})
		}
	}
	return tags, nil
}
// DescribeECSTagsForInstance calls DescribeTags API to get the EC2 tags of the
// instance id, and return it back as ECS tags