Alex
Alex

Reputation: 657

Listing ec2 details with boto3 in Lambda

Is there a way to get results of EC2 describe instances using boto3 in AWS Lambda? The output is preferably in JSON so that it can be parsed by another function. All EC2 instances in the JSON output.

Upvotes: 0

Views: 601

Answers (1)

Jason Warta
Jason Warta

Reputation: 450

Does the provided describe_instances function not do what you need?

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances

import boto3
client = boto3.client('ec2')
client.describe_instances()

You'll find that for almost all of the tools you can access through the AWS CLI, there is a boto3 equivalent, and in many cases, boto3 offers a more refined option in addition to the expected one.

Upvotes: 2

Related Questions