Fix image upgrade bug and add no-startup-command.

This commit is contained in:
Thomas Stokes
2024-03-13 12:33:26 +01:00
parent 1f40b7e450
commit 70a42fc9ba
@@ -17,7 +17,8 @@ if [[ "$#" -eq 0 ]];then
fi
addSelfToNLB() {
if ! ec2-metadata --user-data | grep "^image-upgrade$" ; then
user_data=$(ec2-metadata --user-data | sed -e 's/^user-data: //')
if ! echo "$user_data" | grep "^image-upgrade$" && ! echo "$user_data" | grep "^no-startup-automation$" ; then
ec2-metadata --local-ipv4 | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\>" > /var/cache/local-ip
ec2-metadata --availability-zone | grep -o "[a-zA-Z]\+-[a-zA-Z]\+-[0-9a-z]\+\>" > /var/cache/availability-zone
aws elbv2 register-targets --target-group-arn "${targetGroupArn}" --targets Id="${selfIp}",Port=80,AvailabilityZone="${availabilityZone}"