6

I did not think that making a serverless Discord bot would be such a learning experience. The code itself was easy. The hard part was the infrastructure, because I decided to automate it all with Terraform and deploy it on AWS.

Before this project, I had no idea how API Gateways worked. Now I still have very little idea how they work but I managed to build one anyway. Eventually. And then I had to figure out how to automate the deployment of a lambda layer and function that would both still be managed in the Terraform state, with any code changes triggering a rebuild and update for the resource.

And then I had to untangle a dependency mess because API Gateways have some weird issues where two resources that have no explicit dependencies on each other will throw an error if they don't deploy in the right order.

And then I went the wrong way with Github actions trying to conditionally chain multiple workflows together before I realized I could just put multiple jobs with conditions in a single workflow.

And now after all that work over the course of 2 days, I have a bot that does this:

Comments
  • 0
    Are you using api gateway v1 ( rest api) or v2 (http api)?

    For me that v1 is cancer unfortunately, only defeats and complexity came from it in my experience

    PS: lambdas have a dedicated url that you can use without alb or api-gw, but I just discovered it in this last weekend
  • 0
    They apparently added the dedicated url feature in November last year. So it's relatively new, which explains why all of the blog posts, tutorials, and Stack Overflow questions I found said it was impossible to invoke it without an API Gateway in front of it.

    Had to use a v1 REST gateway because v2 is missing some important features, but I may be able to rewrite my lambda to take a direct request to its own url and drop the API Gateway entirely. Thanks!
Add Comment