-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws.env
executable file
·73 lines (59 loc) · 3.24 KB
/
aws.env
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# This script:
# - gets all variables for this environment from the AWS parameter store
# - Store these as environment variables so we avoid costly call so the AWS parameter store.
# Make sure to
# - configure your AWS CLI accordingly <-- this is done automatically by Travis CI (see .travis.yml)
# - update the variable in the travis CI setting for this repo if needed
# The variable TRAVIS_AWS_PROFILE is set when .travis.yml runs
# If you need to run this locally,
# - uncomment the below line
# - replace the value of the variable with the relevant aws-cli profile for your machine.
# TRAVIS_AWS_PROFILE=replace-with-the-aws-profile-you-need-to-test
if [ -z ${TRAVIS_AWS_PROFILE} ]; then
echo "We have no value for the AWS CLI profile we need to use"
exit 1
else
echo "AWS CLI profile in use is ${TRAVIS_AWS_PROFILE}"
fi
# First, we create a procedure that helps us retrieve the variables from the AWS parameter store
getparam () {
aws --profile ${TRAVIS_AWS_PROFILE} ssm get-parameters --names "$1" --with-decryption --query Parameters[0].Value --output text
}
echo "START - Get the environment variables from the AWS parameter store"
echo "Some of the environment variables that we are setting are:"
# Variables that are maintained in the AWS parameter store for the environment:
# General information:
export INSTALLATION_ID=$(getparam INSTALLATION_ID)
if [ -z ${INSTALLATION_ID} ]; then
echo "We have no value for the INSTALLATION_ID"
exit 1
else
echo " * Installation ID is: $INSTALLATION_ID"
fi
export STAGE=$(getparam STAGE)
echo " * This is the **$STAGE** environment"
export DOMAIN=$(getparam DOMAIN)
echo " * The domain is: $DOMAIN"
export DEFAULT_REGION=$(getparam DEFAULT_REGION)
echo " * The default AWS region is: $DEFAULT_REGION"
export DEFAULT_SECURITY_GROUP=$(getparam DEFAULT_SECURITY_GROUP)
export PRIVATE_SUBNET_1=$(getparam PRIVATE_SUBNET_1)
export PRIVATE_SUBNET_2=$(getparam PRIVATE_SUBNET_2)
export PRIVATE_SUBNET_3=$(getparam PRIVATE_SUBNET_3)
# For the BZ installation:
export MYSQL_HOST=$(getparam MYSQL_HOST)
echo " * The RDS database is accessible at: $MYSQL_HOST"
export MYSQL_PORT=$(getparam MYSQL_PORT)
echo " * The port for the RDS database is: $MYSQL_PORT"
export BUGZILLA_DB_NAME=$(getparam BUGZILLA_DB_NAME)
echo " * The database for the BZ installation is: $BUGZILLA_DB_NAME"
export BUGZILLA_DB_USER=$(getparam BUGZILLA_DB_USER)
echo " * The database user we use for interactions with the BZ database is: $BUGZILLA_DB_USER"
export BUGZILLA_DB_PASSWORD=$(getparam BUGZILLA_DB_PASSWORD)
echo " * The password for the database user we use for interactions with the BZ database is: **hidden secret**"
# For the API:
export LAMBDA_TO_RDS_SECURITY_GROUP=$(getparam LAMBDA_TO_RDS_SECURITY_GROUP)
export API_ACCESS_TOKEN=$(getparam API_ACCESS_TOKEN)
export EMAIL_FOR_NOTIFICATION_UNIT=$(getparam EMAIL_FOR_NOTIFICATION_UNIT)
echo "END - Get the environment variables from the AWS parameter store"