Skip to content

Commit ae64f49

Browse files
committed
Merge pull request #4259 from sbuss/aws-private-ip
fix(contrib) AWS instances may only have a private IP
2 parents d3a333f + 93662a3 commit ae64f49

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

contrib/aws/provision-aws-cluster.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,24 @@ ELB_NAME=$(aws elb describe-load-balancers \
136136
$EXTRA_AWS_CLI_ARGS | grep -F $ELB_DNS_NAME | head -n1 | cut -f2)
137137
echo "Using ELB $ELB_NAME at $ELB_DNS_NAME"
138138
139-
FIRST_INSTANCE=$(aws ec2 describe-instances \
140-
--filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
141-
--query 'Reservations[].Instances[].[PublicIpAddress]' \
142-
--output text \
143-
$EXTRA_AWS_CLI_ARGS | head -1)
139+
# Instance launched into a VPC may not have a PublicIPAddress
140+
for ip_type in PublicIpAddress PrivateIpAddress; do
141+
FIRST_INSTANCE=$(aws ec2 describe-instances \
142+
--filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
143+
--query "Reservations[].Instances[].[$ip_type]" \
144+
--output text \
145+
$EXTRA_AWS_CLI_ARGS | head -1)
146+
if [[ ! $FIRST_INSTANCE == "None" ]]; then
147+
break
148+
fi
149+
done
150+
151+
if [[ $FIRST_INSTANCE == "None" ]]; then
152+
echo_red "The IP of any of your instances could not be found."
153+
echo_red "Ensure that the cloudformation stack was created successfully."
154+
exit 1
155+
fi
156+
144157
export DEISCTL_TUNNEL=$FIRST_INSTANCE
145158
146159
# loop until etcd2 / fleet are up and running

0 commit comments

Comments
 (0)