TT#41051 Allow elastic IP reassociation, otherwise impossible to access Amazon EC2 NGCP AMI

At the moment the following error happens:

> + ec2-associate-address --region eu-west-1 --allocation-id eipalloc-0a96e07d4355e12fb --instance i-0895e8ae5e15da659
> Client.Resource.AlreadyAssociated: resource eipalloc-0a96e07d4355e12fb is already associated with associate-id eipassoc-02667670aacf004de (Service: AmazonEC2; Status Code: 400; Error Code: Resource.AlreadyAssociated; Request ID: 4f646755-90eb-49bc-9100-2603fa5eb3f9)

Which caused the non-accessible DNS name resolution:

> ++ ec2-describe-instances --region eu-west-1 --filter instance-id=i-0895e8ae5e15da659 | awk '/INSTANCE/ {print $4}'
> + HOSTNAME=ip-10-0-0-109.eu-west-1.compute.internal
> ...
> + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /var/lib/jenkins/.ssh/jenkins-ngcp-create-ami.pem admin@ip-10-0-0-109.eu-west-1.compute.internal 'grep -q '\''Installation finished. Thanks for choosing NGCP'\'' /var/log/ngcp-installer-debug.log'
> ssh: Could not resolve hostname ip-10-0-0-109.eu-west-1.compute.internal: Name or service not known

We need to ensure public IP will be reassociated from the old Amazon machine to
newly started Amazon VM, using option --allow-reassociation here:

> --allow-reassociation
>     Allows an Elastic IP address that is already associated with an
>     instance or a network interface to be re-associated with the
>     specified instance or network interface. Otherwise, the operation
>     fails.

Change-Id: I5b813c7de313743e6ad8a44abb57c3c40216d067
changes/34/22934/1
Alexander Lutay 8 years ago
parent 1338b27c85
commit b4da7c9165

@ -433,10 +433,10 @@ fi
# webserver areas
if [ -n "$ALLOCATION_ID" ] ; then
echo "Associating elastic IP $ELASTIC_IP allocation ID ${ALLOCATION_ID} with instance ID $INSTANCE_ID"
ec2-associate-address --region "${AWS_REGION}" --allocation-id "${ALLOCATION_ID}" --instance "${INSTANCE_ID}"
ec2-associate-address --region "${AWS_REGION}" --allocation-id "${ALLOCATION_ID}" --instance "${INSTANCE_ID}" --allow-reassociation
elif [ -n "$ELASTIC_IP" ] ; then
echo "Associating elastic IP $ELASTIC_IP with instance ID $INSTANCE_ID"
ec2-associate-address --region "${AWS_REGION}" "${ELASTIC_IP}" -i "${INSTANCE_ID}"
ec2-associate-address --region "${AWS_REGION}" "${ELASTIC_IP}" -i "${INSTANCE_ID}" --allow-reassociation
fi
HOSTNAME="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id="$INSTANCE_ID" | awk '/INSTANCE/ {print $4}')"

Loading…
Cancel
Save