-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_config_drift.sh
More file actions
executable file
·36 lines (26 loc) · 996 Bytes
/
launch_config_drift.sh
File metadata and controls
executable file
·36 lines (26 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
OK=0
NONOK=1
UNKNOWN=2
export $(cat /run/metadata/coreos | xargs)
instance_id="${COREOS_EC2_INSTANCE_ID}"
instances="$(aws autoscaling describe-auto-scaling-instances --instance-ids "${instance_id}")"
if [ "$(echo "${instances}" | jq '.AutoScalingInstances | length')" -eq "0" ]
then
exit $UNKNOWN
fi
instance="$(echo "${instances}" | jq '.AutoScalingInstances[0]')"
instance_launch_config="$(echo "${instance}" | jq -r .LaunchTemplate.LaunchTemplateName)"
instance_asg="$(echo "${instance}" | jq -r .AutoScalingGroupName)"
asgs="$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ${instance_asg})"
if [ "$(echo "${asgs}" | jq '.AutoScalingGroups | length')" -eq "0" ]
then
exit $UNKNOWN
fi
asg_launch_config="$(echo "${asgs}" | jq -r '.AutoScalingGroups[0].MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateName')"
if [ "${instance_launch_config}" = "${asg_launch_config}" ]
then
exit $OK
else
exit $NONOK
fi