Python Forum
Fetching private ip address from instances of an autoscaling group
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fetching private ip address from instances of an autoscaling group
#1
Dear All,

I am trying to fetch private ip address of an instances launched into autoscaling group.
There is no property 'private-ip-address' for autoscaling scaling group instances.
However I need it to display on cloudwatch dashboard as instance id is not much help.
This is what I'm trying

#!/usr/bin/env python

import boto3

ec2 = boto3.resource('ec2')

def get_instances():
    client = boto3.client('autoscaling')
    paginator = client.get_paginator('describe_auto_scaling_groups')
    groups = paginator.paginate().build_full_result()

    for asg in groups['AutoScalingGroups']:
        print asg['AutoScalingGroupName']
        instance_ids = [i for i in asg['Instances']]
        running_instances = ec2.instances.filter(Filters=[{}])
        for instance in running_instances:
            print(instance.id, instance.public_dns_name, instance.private_ip_address)

if __name__ == '__main__':
    get_instances()
Appreciate if someone can help
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Lint and private var names PatM 1 699 Dec-15-2022, 05:08 PM
Last Post: deanhystad
  fetching exit status hangs in paramiko saisankalpj 3 1,194 Dec-04-2022, 12:21 AM
Last Post: nilamo
  Fetching the port number using asyncio gary 0 955 Nov-01-2022, 02:53 AM
Last Post: gary
  Unable to import Private Repo using setup.py Bob786 1 1,766 Sep-02-2021, 04:19 PM
Last Post: snippsat
  Fetching data from multiple tables in a single request. swaroop 0 1,906 Jan-09-2021, 04:23 PM
Last Post: swaroop
  python 3 dns lookup private domain didact 1 2,578 Sep-19-2020, 06:01 PM
Last Post: bowlofred
  [split] Помощь по приватным ключам/Private key help sairam17519 0 1,612 Sep-07-2020, 12:55 PM
Last Post: sairam17519
  Download file from Private GitHub rep vinuvt 0 1,981 Jul-27-2020, 11:38 AM
Last Post: vinuvt
  Private package distribution abomination disadvantages research andreir 2 2,166 May-07-2020, 12:32 AM
Last Post: andreir
  Fetching data from Sklearn zaki424160 2 4,129 Jul-09-2019, 05:20 AM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020