Jane S.
Jane S.

Reputation: 245

Is there a way to list launch configurations sorted by CreatedTime via aws-cli?

I am finding a way on how to list launch configurations sorted by CreatedTime. When I ran this command below, it does not return the oldest LC:

aws autoscaling describe-launch-configurations --max-items 1

Is there a way for this? Thank you!

Upvotes: 0

Views: 1347

Answers (1)

spg
spg

Reputation: 9837

You can control the the command's output using a JMESPath expression like this:

aws autoscaling describe-launch-configurations --query 'reverse(sort_by(LaunchConfigurations, &CreatedTime))'

The previous command will list all launch configurations ordered by descending CreatedTime. If you only want to get the latest launch config based on CreatedTime, add the [0] expression at the end of the command:

aws autoscaling describe-launch-configurations --query 'reverse(sort_by(LaunchConfigurations, &CreatedTime))[0]'

Upvotes: 0

Related Questions