üzgünüm, bash senaryolarında hala yeniyim. Yaklaşık 10000 EC2 örneğim var, EC2 örnek türümü değiştirmek için bu bash betiğini oluşturdum, tüm örnek adı ve türü bir dosyada saklanır. kod çalışıyor, ancak örnek örnek üzerinden çalıştırmak çok uzun sürüyor.
tüm EC2 örneklerinde AWS Clı komutunu tek seferde çalıştırabileceğimi bilen var mı ? Teşekkür :)
#!/bin/bash
my_file='test.txt'
declare -a instanceID
declare -a fmo #Future Instance Size
while IFS=, read -r COL1 COL2; do
instanceID+=("$COL1")
fmo+=("$COL2")
done <"$my_file"
len=${#instanceID[@]}
for (( i=0; i < $len; i++)); do
vm_instance_id="${instanceID[$i]}"
vm_type="${fmo[$i]}"
echo Stoping $vm_instance_id
aws ec2 stop-instances --instance-ids $vm_instance_id
echo " Waiting for $vm_instance_id state to be STOP "
aws ec2 wait instance-stopped --instance-ids $vm_instance_id
echo Resizing $vm_instance_id to $vm_type
aws ec2 modify-instance-attribute --instance-id $vm_instance_id --instance-type $vm_type
echo Starting $vm_instance_id
aws ec2 start-instances --instance-ids $vm_instance_id
done