Hi@akhtar,
To do this task, you have to use three services (EC2, IAM, Lambda) of AWS.
import json
import boto3
from pprint import pprint
def lambda_handler(event, context):
# TODO implement
client = boto3.client("ec2")
status = client.describe_instance_status(IncludeAllInstances = True)
#pprint(status)
for i in status["InstanceStatuses"]:
print("AvailabilityZone :", i["AvailabilityZone"])
print("InstanceId :", i["InstanceId"])
print("InstanceState :", i["InstanceState"])
print("InstanceStatus", i["InstanceStatus"])
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Thank You