Skip to content

Commit

Permalink
Merge branch 'main' into green-line-new-trains
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte authored Aug 3, 2023
2 parents 238de2e + 7b78481 commit 325eab8
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 36 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ This is an app that can host all our data crunching jobs, especially those that
It uses Chalice, which makes it easy to add new functions that can be triggered on an interval or via rest API endpoint.

So far we have:

- Store MBTA Alerts data daily.
- Store number of trips with new trains on Orange and Red line daily.
- Store Bluebikes station status data every 5 min.

To add a new lambda function, put the methods you need in a new file in chalicelib/.
Then add your trigger in app.py.
Then, add a policy.json file for any permissions you might need in .chalice/, updating .chalice/config.json accordingly.
Lastly, if you need secret environment variables, update envvars.json and make sure they are passed
Lastly, if you need secret environment variables, update resources.json and make sure they are passed
with --parameter-override in the cloudformation deploy step of deploy.sh.
(Non-secret envvars can be added to config.json directly.)
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ poetry export -f requirements.txt --output ingestor/requirements.txt --without-h

pushd ingestor/

poetry run chalice package --stage prod --merge-template .chalice/envvars.json --merge-template .chalice/dynamo_tables.json cfn/
poetry run chalice package --stage prod --merge-template .chalice/resources.json cfn/
aws cloudformation package --template-file cfn/sam.json --s3-bucket $BUCKET --output-template-file cfn/packaged.yaml
aws cloudformation deploy --template-file cfn/packaged.yaml --stack-name $STACK_NAME \
--capabilities CAPABILITY_NAMED_IAM --no-fail-on-empty-changeset \
Expand Down
34 changes: 0 additions & 34 deletions ingestor/.chalice/envvars.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,157 @@
{
"Parameters": {
"MbtaV2ApiKey": {
"Type": "String",
"Description": "MBTA Performance API Key"
},
"DDApiKey": {
"Type": "String",
"Description": "Datadog API key."
}
},
"Resources": {
"PopulateDeliveredTripMetrics": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"PopulateAggDeliveredTripMetrics": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"StoreYesterdayAlerts": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"MBTA_V2_API_KEY": { "Ref": "MbtaV2ApiKey" },
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"StoreNewTrainRuns": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"MBTA_V2_API_KEY": { "Ref": "MbtaV2ApiKey" },
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"BbStoreStationStatus": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"BbStoreStationInfo": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"BbCalcDailyStats": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateDeliveredTripMetrics": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateAggTripMetrics": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateDeliveredTripMetricsYesterday": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateGtfs": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateRidership": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"UpdateSpeedRestrictions": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"StoreLandingData": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": { "Ref": "DDApiKey" }
}
}
}
},
"OverviewStats": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
Expand Down

0 comments on commit 325eab8

Please sign in to comment.