简体   繁体   English

有没有办法列出通过aws-cli按CreatedTime排序的启动配置?

[英]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 . 我正在寻找一种方法,以列出由CreatedTime排序的启动配置。 When I ran this command below, it does not return the oldest LC: 当我在下面运行此命令时,它不会返回最早的LC:

aws autoscaling describe-launch-configurations --max-items 1 AWS自动缩放describe-launch-configuration --max-items 1

Is there a way for this? 有办法吗? Thank you! 谢谢!

You can control the the command's output using a JMESPath expression like this: 您可以使用JMESPath表达式来控制命令的输出,如下所示:

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

The previous command will list all launch configurations ordered by descending CreatedTime . CreatedTime命令将列出按CreatedTime降序CreatedTime所有启动配置。 If you only want to get the latest launch config based on CreatedTime , add the [0] expression at the end of the command: 如果只想获取基于CreatedTime的最新启动配置,请在命令末尾添加[0]表达式:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM