yasudacloudの日記

札幌に住むソフトウェアエンジニア

Running Strapi serverless built with Terraform

I was looking for a way to run Strapi serverless.

blog.vikfand.com

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.

yasuda.cloud

 

infrastructure

The AWS resources we will be creating are EFS, Lambda,ECR, IAM, SecurityGroup, VPC, and API Gateway. The source code is presented first.

github.com

Here's a brief description.

 

ECR (ecr.tf)

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.

Lambda (lambda.tf)

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.

 

issue

  1. Cold standby startup is slow and needs to be addressed. For example, periodically executing Lambda?
  2. Backup and admin functions are not considered.
  3. 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!😏