by shigemk2

当面は技術的なことしか書かない

boto3 ec2.instances

boto3 ec2.instances

適当に。IAMロールとかはちゃんとしようね。

import boto3
ec2 = boto3.resource('ec2')
instances = ec2.instances.filter(
    Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
for instance in instances:
    print(instance.id)
    print(instance.instance_type)

http://boto3.readthedocs.io/en/latest/guide/migrationec2.html