-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-service.sh
20 lines (12 loc) · 891 Bytes
/
start-service.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash -xe
source /home/ec2-user/.bash_profile
cd /home/ec2-user/app/release
# Query the EC2 metadata service for this instance's region
#REGION=`curl -s http://169.254.169.254/latest/dynamic/instanceidentity/document | jq .region -r`
REGION="`wget -qO- http://instance-data/latest/meta-data/placement/availability-zone | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
# Query the EC2 metadata service for this instance's instance-id
#export INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instanceid`
export INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`"
# Query EC2 describeTags method and pull out the CFN Logical ID for this instance
export STACK_NAME=`aws --region $REGION ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCE_ID}" "Name=key,Values=aws:cloudformation:stack-name" | jq -r ".Tags[0].Value"`
npm run start