Determining Amazon EC2 instance creation date/time

后端 未结 5 619
灰色年华
灰色年华 2021-01-02 02:32

Is it possible to determine (via boto) when a particular EC2 instance was created?

http://boto.readthedocs.org/en/latest/ref/ec2.html doesn\'t seem to be giving any

5条回答
  •  难免孤独
    2021-01-02 03:03

    As shown here:

    http://boto.readthedocs.org/en/latest/ref/ec2.html#module-boto.ec2.instance

    Each Instance object has an attribute called launch_time which contains a IS08601 datetime string representing when the instance was launched.

    In boto, you could do something like this:

    import boto.ec2
    
    conn = boto.ec2.connect_to_region('us-west-1')
    reservations = conn.get_all_instances()
    for r in reservations:
        for i in r.instances:
            print('%s\t%s' % (i.id, i.launch_time)
    

提交回复
热议问题