File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,10 +22,17 @@ if [ -z "${instance_id}" ]; then
2222 exit $UNKNOWN
2323fi
2424
25- instances= " $( aws autoscaling describe-auto-scaling-instances --instance-ids " ${instance_id} " 2> /dev/null ) "
25+ INSTANCE_CACHE= " /tmp/npd_asg_instance_cache "
2626
27- if [ -z " ${instances} " ] || ! echo " ${instances} " | jq empty 2> /dev/null; then
28- exit $UNKNOWN
27+ if [ -f " $INSTANCE_CACHE " ]; then
28+ instances=" $( cat " $INSTANCE_CACHE " ) "
29+ else
30+ instances=" $( aws autoscaling describe-auto-scaling-instances --instance-ids " ${instance_id} " 2>&1 ) "
31+ if [ $? -ne 0 ]; then
32+ echo " describe-auto-scaling-instances: ${instances} " >&2
33+ exit $UNKNOWN
34+ fi
35+ echo " ${instances} " > " $INSTANCE_CACHE "
2936fi
3037
3138if [ " $( echo " ${instances} " | jq ' .AutoScalingInstances | length' ) " -eq " 0" ]; then
@@ -38,9 +45,9 @@ instance_launch_template_version="$(echo "${instance}" | jq -r .LaunchTemplate.V
3845instance_asg=" $( echo " ${instance} " | jq -r .AutoScalingGroupName) "
3946
4047# Get ASG's current launch template (still requires AWS API)
41- asgs=" $( aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names " ${instance_asg} " 2> /dev/null ) "
42-
43- if [ -z " ${asgs} " ] || ! echo " ${asgs} " | jq empty 2> /dev/null ; then
48+ asgs=" $( aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names " ${instance_asg} " 2>&1 ) "
49+ if [ $? -ne 0 ] ; then
50+ echo " describe-auto-scaling-groups: ${asgs} " >&2
4451 exit $UNKNOWN
4552fi
4653
You can’t perform that action at this time.
0 commit comments