-
Notifications
You must be signed in to change notification settings - Fork 20
/
configure
executable file
·45 lines (37 loc) · 1 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
#
# AMI Baking Configuration
#
# lookup the ciinabox vpc details
#
# base2Services <[email protected]>
#
set -e
[ -r /etc/environment ] && . /etc/environment
# Logging
function log() {
LEVEL="${1^^}"
MESSAGE="$2"
DATESTAMP="`date +%r`"
echo "${DATESTAMP} [${LEVEL}] -- ${MESSAGE}"
}
SCRIPT_PATH="`dirname \"$0\"`"
SCRIPT_PATH="`( cd \"$SCRIPT_PATH\" && pwd )`"
CIINABOX_NAME=${1}
REGION=${2}
AMI_USERS=${3}
eval $(aws cloudformation describe-stacks --stack-name ${CIINABOX_NAME} --query 'Stacks[*].Outputs[*].{Key:OutputKey, Value:OutputValue}' --region ${REGION} --output text | tr -s '\t' | tr '\t' '=')
if [[ "x${ECSInstanceProfile}" == "x" ]]; then
ECSInstanceProfile="packer"
fi
cat <<EOT > ${SCRIPT_PATH}/base_params.json
{
"region": "${Region}",
"vpc_id": "${VPCId}",
"subnet_id": "${ECSPrivateSubnetA}",
"security_group": "${SecurityGroup}",
"packer_role": "${ECSRole}",
"packer_instance_profile": "${ECSInstanceProfile}",
"ami_users": "${AMI_USERS}"
}
EOT