[英]Getting Syntax Error: Unexpected keyword END while running `Execute Immediate`
[英]Getting line 19: syntax error: unexpected end of file
我正在嘗試將 Elastic IP 地址與 Auto scaling 組相關聯,因此只要自動縮放觸發,它就會自動與 EIP 相關聯。
為此,我試圖在用戶數據中添加腳本。
我的意圖是我們有 2 個服務器,因此它與 2 個 EIP 相關聯,每當自動縮放觸發時,它必須檢查 EIP 是否空閑,如果空閑,它必須使用實例 ID 與該實例相關聯。
因此,當我運行腳本時,我得到第 19 行:語法錯誤:文件意外結束。 我檢查了縮進,但我認為它是正確的。
#!/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
您錯過了for
循環的最終done
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.