I was looking for a way to run Strapi serverless.
I found the article very informative.
Serverless frameworks are very good, but I would like to consider how to build one using Terraform.
The database uses SQLite.
Please also read our previous article on building with EFS and SQLite.
The AWS resources we will be creating are EFS, Lambda,ECR, IAM, SecurityGroup, VPC, and API Gateway. The source code is presented first.
Here's a brief description.
Due to the large file size of Strapi, a container is used to deploy Lambda. The GitHub code is Docker built from M1 Mac and pushed to ECR.
API Gateway (apigateway.tf)
Forward all requests to Lambda. Since we are not using a custom domain, the root path is the stage name. For example, if the stage name is api, the URL will look like this.
If it does not work, enable logging and check APIGateway and Lambda Cloud Watch, respectively.
At least 256 MB of memory is required. The configuration is a bit complicated because a VPC and security group are needed to mount the EFS.
- Cold standby startup is slow and needs to be addressed. For example, periodically executing Lambda?
- Backup and admin functions are not considered.
- If you have any questions, please do not hesitate to contact me. I am also in the process of learning about going serverless.
Thanks to the developers who wrote the Serverless FW article.
And to the developers at Strapi, and to DeepL!😏