-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate NTT to Chalice from flask/ec2 (#205)
* Migrate NTT to Chalice from flask/ec2 * Fixing last seen data * Remove initial data * Default to green * Fixing font size on safari
- Loading branch information
1 parent
c564321
commit 48362a7
Showing
62 changed files
with
2,837 additions
and
4,938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
.DS_Store | ||
node_modules | ||
.vscode | ||
dist/ | ||
venv/ | ||
hosts | ||
inventory | ||
*.pem | ||
last_seen.json | ||
traintracker-dev.nginx.conf | ||
__pycache__/ | ||
devops/ec2-secrets.py | ||
|
||
requirements.txt | ||
__pycache__/ | ||
*.pyc | ||
server/**/__pycache__ | ||
requirements.txt | ||
server/cfn/* | ||
server/.chalice/deployments/* | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18 | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
export AWS_PROFILE=transitmatters | ||
export AWS_REGION=us-east-1 | ||
export AWS_DEFAULT_REGION=us-east-1 | ||
export AWS_PAGER="" | ||
|
||
PRODUCTION=false | ||
|
||
# Argument parsing | ||
# pass "-p" flag to deploy to production | ||
|
||
while getopts "pc" opt; do | ||
case $opt in | ||
p) | ||
PRODUCTION=true | ||
;; | ||
esac | ||
done | ||
|
||
|
||
$PRODUCTION && ENV_SUFFIX="" || ENV_SUFFIX="-beta" | ||
$PRODUCTION && CHALICE_STAGE="production" || CHALICE_STAGE="beta" | ||
$PRODUCTION && STACK_NAME="ntt" || STACK_NAME="ntt-beta" | ||
|
||
$PRODUCTION && FRONTEND_ZONE="traintracker.transitmatters.org" || FRONTEND_ZONE="labs.transitmatters.org" | ||
$PRODUCTION && FRONTEND_CERT_ARN="$TM_NTT_CERT_ARN" || FRONTEND_CERT_ARN="$TM_LABS_WILDCARD_CERT_ARN" | ||
$PRODUCTION && FRONTEND_DOMAIN_PREFIX="" || FRONTEND_DOMAIN_PREFIX="ntt-beta." | ||
|
||
BACKEND_ZONE="labs.transitmatters.org" | ||
BACKEND_CERT_ARN="$TM_LABS_WILDCARD_CERT_ARN" | ||
$PRODUCTION && BACKEND_DOMAIN_PREFIX="traintracker-api." || BACKEND_DOMAIN_PREFIX="ntt-api-beta." | ||
|
||
BACKEND_BUCKET=ntt-backend$ENV_SUFFIX | ||
FRONTEND_HOSTNAME=$FRONTEND_DOMAIN_PREFIX$FRONTEND_ZONE # Must match in .chalice/config.json! | ||
BACKEND_HOSTNAME=$BACKEND_DOMAIN_PREFIX$BACKEND_ZONE # Must match in .chalice/config.json! | ||
|
||
|
||
# Ensure required secrets are set | ||
if [[ -z "$DD_API_KEY" ]]; then | ||
echo "Must provide DD_API_KEY in environment to deploy" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# Identify the version and commit of the current deploy | ||
GIT_VERSION=`git describe --tags --always` | ||
GIT_SHA=`git rev-parse HEAD` | ||
GIT_ABR_VERSION=`git describe --tags --abbrev=0` | ||
echo "Deploying version $GIT_VERSION | $GIT_SHA" | ||
|
||
# Adding some datadog tags to get better data | ||
DD_TAGS="git.commit.sha:$GIT_SHA,git.repository_url:github.com/transitmatters/parking-explorer" | ||
|
||
npm run build | ||
|
||
echo "Deploying Train Tracker CloudFormation stack to $HOSTNAME..." | ||
echo "View stack log here: https://$AWS_REGION.console.aws.amazon.com/cloudformation/home?region=$AWS_REGION" | ||
|
||
pushd server/ > /dev/null | ||
poetry export --without-hashes --output requirements.txt | ||
poetry run chalice package --stage $CHALICE_STAGE --merge-template cloudformation.json cfn/ | ||
aws cloudformation package --template-file cfn/sam.json --s3-bucket $BACKEND_BUCKET --output-template-file cfn/packaged.yaml | ||
aws cloudformation deploy --stack-name $STACK_NAME \ | ||
--template-file cfn/packaged.yaml \ | ||
--capabilities CAPABILITY_NAMED_IAM \ | ||
--no-fail-on-empty-changeset \ | ||
--parameter-overrides \ | ||
TMFrontendHostname=$FRONTEND_HOSTNAME \ | ||
TMFrontendZone=$FRONTEND_ZONE \ | ||
TMFrontendCertArn=$FRONTEND_CERT_ARN \ | ||
TMBackendCertArn=$BACKEND_CERT_ARN \ | ||
TMBackendHostname=$BACKEND_HOSTNAME \ | ||
TMBackendZone=$BACKEND_ZONE \ | ||
MbtaV3ApiKey=$MBTA_V3_API_KEY \ | ||
DDApiKey=$DD_API_KEY \ | ||
GitVersion=$GIT_VERSION \ | ||
DDTags=$DD_TAGS | ||
|
||
popd > /dev/null | ||
aws s3 sync dist/ s3://$FRONTEND_HOSTNAME | ||
|
||
# Grab the cloudfront ID and invalidate its cache | ||
CLOUDFRONT_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, '$FRONTEND_HOSTNAME')].Id | [0]" --output text) | ||
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID --paths "/*" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.