Starting notes of songs. A Telegram bot calling a GraphQL API sitting on top of a DynamoDB table.
How to get things up and running:
- Build lambda layers for Telegram bot and API
- run
py build_layers.py
(see below for a more detailed description)
- run
cd infra && terraform apply
- Set SSM parameters
- acquire Telegram bot token
- generate a secret to use as a key for Fernet (see e.g. here)
- set the above mentioned to env vars
BOT_TOKEN
andFERNET_KEY
and runpy set_ssm_parameters.py
- Generate a superuser token and add it to the DynamoDB table
- you can use
generate_superuser_token.py
to create the token. Create record in DynamoDB withpk=token, sk=superuser, value=<key>
- the type of
value
in DDB is binary, which only accepts base64 - the above mentioned script takes this into account, and prints out a base64-encoded value
- you can use
- Set up a webhook to the bot's function url
- check the API's URL and set it as an environment variable
API_URL
and runpy set_webhook.py
- you can do
terraform show aws_lambda_function_url.graph_api_lambda_url
to get the value - you could probably automate this with lambda somehow, too.
- you can do
- after this the bot should be functional!
- check the API's URL and set it as an environment variable
Terraform doesn't handle lambda layer building particularly well, so there's a utility script build_layers.py
which:
- Exports dependencies from poetry
pip install
s the dependencies to gitignored folders- zips the folders
This script is handy when doing version upgrades or adding new dependencies. Packaging everything with Docker might be a nicer option, though.
Run uvicorn graph.lib.schema:app
to start a local API instance (against production DB).