@@ -23,6 +23,10 @@ if ! which aws > /dev/null; then
2323 exit 1
2424fi
2525
26+ if [ ! -z " $AWS_CLI_PROFILE " ]; then
27+ EXTRA_AWS_CLI_ARGS+=" --profile $AWS_CLI_PROFILE "
28+ fi
29+
2630if [ -z " $DEIS_NUM_INSTANCES " ]; then
2731 DEIS_NUM_INSTANCES=3
2832fi
@@ -47,7 +51,8 @@ bailout() {
4751aws cloudformation create-stack \
4852 --template-body " $( $THIS_DIR /gen-json.py) " \
4953 --stack-name $STACK_NAME \
50- --parameters " $( < $THIS_DIR /cloudformation.json) "
54+ --parameters " $( < $THIS_DIR /cloudformation.json) " \
55+ $EXTRA_AWS_CLI_ARGS
5156
5257# loop until the instances are created
5358ATTEMPTS=60
@@ -62,20 +67,22 @@ until [ $(wc -w <<< $INSTANCE_IDS) -eq $DEIS_NUM_INSTANCES -a "$STACK_STATUS" =
6267 exit 1
6368 fi
6469
65- STACK_STATUS=$( aws --output text cloudformation describe-stacks --stack-name $STACK_NAME --query ' Stacks[].StackStatus' )
66- if [ $STACK_STATUS != " CREATE_IN_PROGRESS" -a $STACK_STATUS != " CREATE_COMPLETE" ] ; then
70+ STACK_STATUS=$( aws --output text cloudformation describe-stacks --stack-name $STACK_NAME --query ' Stacks[].StackStatus' $EXTRA_AWS_CLI_ARGS )
71+ if [ $STACK_STATUS != " CREATE_IN_PROGRESS" -a $STACK_STATUS != " CREATE_COMPLETE" ] ; then
6772 echo " error creating stack: "
6873 aws --output text cloudformation describe-stack-events \
6974 --stack-name $STACK_NAME \
70- --query ' StackEvents[?ResourceStatus==`CREATE_FAILED`].[LogicalResourceId,ResourceStatusReason]'
75+ --query ' StackEvents[?ResourceStatus==`CREATE_FAILED`].[LogicalResourceId,ResourceStatusReason]' \
76+ $EXTRA_AWS_CLI_ARGS
7177 bailout
7278 exit 1
7379 fi
7480
7581 INSTANCE_IDS=$( aws ec2 describe-instances \
7682 --filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
7783 --query ' Reservations[].Instances[].[ InstanceId ]' \
78- --output text)
84+ --output text \
85+ $EXTRA_AWS_CLI_ARGS )
7986
8087 echo " Waiting for instances to be provisioned ($STACK_STATUS , $( expr 61 - $COUNTER ) 0s) ..."
8188 sleep $SLEEPTIME
@@ -100,7 +107,8 @@ until [ `wc -w <<< $INSTANCE_STATUSES` -eq $DEIS_NUM_INSTANCES ]; do
100107 --filters Name=instance-status.reachability,Values=passed \
101108 --instance-ids $INSTANCE_IDS \
102109 --query ' InstanceStatuses[].[ InstanceId ]' \
103- --output text)
110+ --output text \
111+ $EXTRA_AWS_CLI_ARGS )
104112 let COUNTER=COUNTER+1
105113done
106114
@@ -109,20 +117,23 @@ echo "Instances are available:"
109117aws ec2 describe-instances \
110118 --filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
111119 --query ' Reservations[].Instances[].[InstanceId,PublicIpAddress,InstanceType,Placement.AvailabilityZone,State.Name]' \
112- --output text
120+ --output text \
121+ $EXTRA_AWS_CLI_ARGS
113122
114123# get ELB public DNS name through cloudformation
115124# TODO: is "first output value" going to be reliable enough?
116125export ELB_DNS_NAME=$( aws cloudformation describe-stacks \
117126 --stack-name $STACK_NAME \
118127 --max-items 1 \
119128 --query ' Stacks[].[ Outputs[0].[ OutputValue ] ]' \
120- --output=text)
129+ --output=text \
130+ $EXTRA_AWS_CLI_ARGS )
121131
122132# get ELB friendly name through aws elb
123133ELB_NAME=$( aws elb describe-load-balancers \
124134 --query ' LoadBalancerDescriptions[].[ DNSName,LoadBalancerName ]' \
125- --output=text | grep -F $ELB_DNS_NAME | head -n1 | cut -f2)
135+ --output=text \
136+ $EXTRA_AWS_CLI_ARGS | grep -F $ELB_DNS_NAME | head -n1 | cut -f2)
126137echo " Using ELB $ELB_NAME at $ELB_DNS_NAME "
127138
128139echo_green " Your Deis cluster has been successfully deployed to AWS CloudFormation and is started."
@@ -131,7 +142,8 @@ echo_green "Please continue to follow the instructions in the documentation."
131142FIRST_INSTANCE=$( aws ec2 describe-instances \
132143 --filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
133144 --query ' Reservations[].Instances[].[PublicIpAddress]' \
134- --output text | head -1)
145+ --output text \
146+ $EXTRA_AWS_CLI_ARGS | head -1)
135147export DEISCTL_TUNNEL=$FIRST_INSTANCE
136148echo_green " Enabling proxy protocol"
137149
0 commit comments