GPC
GPC

Reputation: 391

How can I get list of all ec2 instances created by an IAM user

We have an AWS account with many IAM user. There are some ec2 instances which are not tagged. How can I get list of all ec2 instances created by an IAM user ?

Upvotes: 0

Views: 863

Answers (3)

Sudharsan Sivasankaran
Sudharsan Sivasankaran

Reputation: 5887

Currently, there is no direct way to find the owner of the instance. Here is the Python Boto3 script which I use.

List all the instances and does API call to cloudtrail to find out who started(ec2:RunInstances) the instance.

https://gist.github.com/sudharsans/39d5eaf8a82b7ccdf8b3230d13ba7d81

Upvotes: 0

FelixEnescu
FelixEnescu

Reputation: 5102

In the AWS Management console you can use Tag Editor to search for resources that are not tagged:

(Optional) In the next Tags box, do any of the following:

Leave the box empty to search for all resources with the specified key and any value.

Select Not tagged to search for resources that do not have the specified tag key.

Select Empty value to search for resources that have the specified tag key but no value.

Upvotes: 0

jarmod
jarmod

Reputation: 78603

You will need to use CloudTrail. All API calls will be logged there, along with access keys identifying the principal that invoked the API. CloudTrail is enabled by default.

Upvotes: 1

Related Questions