[英]Getting line 19: syntax error: unexpected end of file
I'm trying to associate the Elastic IP address with Auto scaling group, so whenever the autoscaling triggers it will automatically associate with the EIP.我正在尝试将 Elastic IP 地址与 Auto scaling 组相关联,因此只要自动缩放触发,它就会自动与 EIP 相关联。
For this I'm trying to add the script in user data.为此,我试图在用户数据中添加脚本。
My intention is to we have 2 servers so its associated with 2 EIP's, whenever the autoscaling triggers it has to check whether the EIP is free or not if its free it has to associate with that instance using the instance id.我的意图是我们有 2 个服务器,因此它与 2 个 EIP 相关联,每当自动缩放触发时,它必须检查 EIP 是否空闲,如果空闲,它必须使用实例 ID 与该实例相关联。
So when i run the script im getting line 19: syntax error: unexpected end of file.因此,当我运行脚本时,我得到第 19 行:语法错误:文件意外结束。 I have checked the indentations but i think its correct.
我检查了缩进,但我认为它是正确的。
#!/bin/bash
INSTANCE_ID=$(ec2-metadata --instance-id | cut -d " " -f 2);
EIP_LIST=(eipalloc-07da69856432f7cef eipalloc-0355263fcb50412ed)
for EIP in $${EIP_LIST}; do
echo"Checkin if EIP is free"
ISFREE=$(aws ec2 describe-addresses --allocation-ids $EIP --query Addresses[].InstanceID --output text --region ap-south-1)
STARTWAIT=$(date +%s)
while [ ! -z "$ISFREE" ]; do
if [ "$(($(date +%s) - $STARTWAIT))" -gt $MAXWAIT ]; then
echo "WARNING: We waited for 30 seconds, we are forcing it now."
ISFREE=""
else
echo "checking the other EIP [$EIP]"
ISFREE=$(aws ec2 describe-adresses --allocation-ids $EIP --query Addresses[].InstanceID --output text --region ap-south-1)
fi
done
echo "Running: aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $EIP --allow-reassociation --region ap-south-1"
aws ec2 association-address --instance-id $INSTANCE_ID --allocation-id $EIP --allow-reassociation --region ap-south-1
You are missing the final done
for the for
-loop.您错过了
for
循环的最终done
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.