0

I want to retrieve a list of EC2 instances which were created in last x days. Here 'created' means the first launch of an instance. Is there a way to do this using AWS CLI or AWS Golang SDK?

I tried looking into Cloudtrail. Apparently, one could filter events within a specified period of time. So if I wanted to do the same for S3 Buckets, I would look for CreateBucket event in last x days. But unfortunately, I could not find a similar EventName for EC2 instances. The RunInstances event is not specific to the first launch of EC2 instances.

mrpandey
  • 627
  • 2
  • 9
  • 17
  • Possible duplicates: https://stackoverflow.com/questions/55284594/how-to-get-the-most-recently-launched-ec2-instance-with-aws-cli – 32cupo Feb 24 '20 at 12:41
  • `RunInstances` _is_ specific to the first launch of instances. Please note that one `RunInstances` command can be used to launch multiple Amazon EC2 instances. – John Rotenstein Feb 25 '20 at 00:13

1 Answers1

1

From the raw AWS CLI this is not possible without further post-processing of the unfiltered results. Please see below for the previous question/answer.

How to get the most recently launched EC2 instance with AWS CLI? - Stack Overflow

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Eric E
  • 199
  • 6