Hi Team,
How to assign Elastic IP'S parallel when we launch instances from AMI using start up script from bamboo.
Could you please suggest on it.
FYI : able to assign elastic ip's sequentially from start up script.
startup script:
========
echo "sleep for some time,Amazon enough time to associate the Elastic IP without interrupting any of the Bamboo processes"
sleep 90
echo "assign elastic Ip to ElasticAgent instance"
export AWS_ACCESS_KEY_ID="*****************
export AWS_SECRET_ACCESS_KEY=*****************
export AWS_DEFAULT_REGION=*******************
export instance_id=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id`
echo $instance_id
aws ec2 describe-addresses --query 'Addresses[?AssociationId==null]' > output.json
cat output.json
EIP=$(cat output.json | jq -r '.[0] | .PublicIp')
echo "EIP:$EIP"
if [ "$EIP" = "NULL" ]; then
echo "***Nothing to be assign to instance***"
else
echo "Assign unused ip to instance"
aws ec2 associate-address --instance-id $instance_id --public-ip $EIP
echo $?
fi
Note: I want 10 to 15 seconds instance launching delay to assign elastic IP'S.
could you please suggest on how to customize above mentioned script or how to delay instance launches from bamboo startup script or any configurations need to be change from AWS side.