Skip to content

[FIX included] Getting group name didn't work for me #2

@slikk66

Description

@slikk66

Even after adding IAM permission for:
Action('autoscaling', 'DescribeAutoScalingInstances'),

My "group" was coming back blank and was not submitting a metric for the ASG, only for the instance. In another part of my project, I got the ASG name of of the instance tags. I've re-written your _get_auto_scaling_group_name() method using the code from our project and now it's working.

Thanks!!

    def _get_auto_scaling_group_name(self, instance_id, region):

        conn = boto.ec2.connect_to_region(region)

        # figure out tags for current instance and pick out the ASG name
        self_filters = {
            'resource-type': 'instance',
            'resource-id': instance_id}

        tags = conn.get_all_tags(filters=self_filters)
        asg_tags = [
            tag
            for tag in tags if tag.name == u'aws:autoscaling:groupName']

        asg_name = None

        # if ASG tag found, return it
        if len(asg_tags) == 1:
            asg_name = asg_tags[0].value
            print "AsgFound: "+asg_name

        return asg_name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions