'boto3 print instances, tasg names and others
I am trying to get a daily report for all ec2 instances.
so I have this
import boto3
ec2 = boto3.resource('ec2',"us-east-1")
#filters = [
# {'Name': 'instance-state-name', 'Values': ['stopped', 'running']}]
instances = ec2.instances.filter(
Filters=[{'Name': 'instance-state-name', 'Values': ['stopped', 'running']}]
)
instancename = ''
for instance in instances:
for tag in instance.tags:
if tag['Key'] == 'Name':
instancename = tag["Value"]
print(instance.id, instance.instance_type, instance.private_ip_address, instance.hypervisor, instancename)
this is working but how do I add the title of each column?
I need column titles like
instanceId instancetype. private IP. hypervisor. instancename
any idea?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
