This PR was an attempt to make the serverless functions use ddb instead. However, the difficulties encountered were greater than the effort to just migrate everything over to Pulumi, and thus PR is now abandoned. I am still leaving the commits here to serve as a reference in the future on why just using serverless did not work as well as expected. 😢
Solution
Technical Decisions made
Existence of 2 state machines definitions
Due to the removal of queues, there is a change in the shape of the message as queues modify the message slightly. This leads to different shapes for the inputs, specifically,
InputPath: $.Records[0].body for the queues, and InputPath: $.body for just using the dynamo db.
Ideally, we could have done something like InputPath: ${Boolean(env:USE_BODY_PATH) ? '$.body' : '$.Records[0].body'} to have some sort of control flow based on the env var at deploy time. However, serverless doesnt do too well custom if conditions like this .
As a hacky workaround, this PR introduces two separate definitions, and have a separate flag in the command line to decide which version infra to deploy.
However, the above attempt also didnt work due to limitation described here. Recontinuing the effort to move to use pulumi, else this going to end up making quite a bit of changes to our stepfunctions lambda code to make this to work
Tests
To mimic an actual site launch process, one can implement write this in server.js:
Problem
This PR was an attempt to make the serverless functions use ddb instead. However, the difficulties encountered were greater than the effort to just migrate everything over to Pulumi, and thus PR is now abandoned. I am still leaving the commits here to serve as a reference in the future on why just using serverless did not work as well as expected. 😢
Solution
Technical Decisions made
Existence of 2 state machines definitions
Due to the removal of queues, there is a change in the shape of the message as queues modify the message slightly. This leads to different shapes for the inputs, specifically,
InputPath: $.Records[0].body
for the queues, andInputPath: $.body
for just using the dynamo db. Ideally, we could have done something likeInputPath: ${Boolean(env:USE_BODY_PATH) ? '$.body' : '$.Records[0].body'}
to have some sort of control flow based on the env var at deploy time. However, serverless doesnt do too well custom if conditions like this .As a hacky workaround, this PR introduces two separate definitions, and have a separate flag in the command line to decide which version infra to deploy. However, the above attempt also didnt work due to limitation described here. Recontinuing the effort to move to use pulumi, else this going to end up making quite a bit of changes to our stepfunctions lambda code to make this to work
Tests
To mimic an actual site launch process, one can implement write this in
server.js
: