mlops-club / awscdk-minecraft

An AWS CDK package written in Python for deploying an entire Minecraft Server Platform-as-a-Service
Other
13 stars 4 forks source link

added a lambda function to the state machine that validates the input… #25

Closed phitoduck closed 1 year ago

phitoduck commented 1 year ago

The last PR started work that this PR finishes. We added an AWS Lambda function to the step function DAG that validates that the input is correct.

{
    "command": "deploy"
}

and

{
    "command": "destroy",
    "destroy_at_utc_time": "some ISO formatted UTC timestamp in the future"
}

are both considered valid inputs. Everything else is invalid. Eventually, we'll probably want to not require that destroy_at_utc_time would be set, and instead the server would delete right away, rather than in the future. That would be important for instantly stopping the server.

Here's the new state machine.

image

The lambda function handler has some test cases inside. We didn't use a python testing framework for these. I skipped that because I didn't want the overhead of putting the tests in another file and rigging up the PYTHONPATH to make it so those tests could import from the handler. Instead, the test cases are part of the if __name__ == "__main__" block in index.py.

Next up:

We'll add a Wait task to the state machine so that the "destroy" command waits until the given timestamp to actually destroy the server.