This repository contains sample code for building AWS infrastructure resources with Terraform using Lambda and API Gateway configuration for an API utilizing serverless-express.
The diagram created using pluralith.
terraform
βββ environments π Environment-specific configuration files
β βββ common
β β βββ README.md
β β βββ backend.tf
β β βββ main.tf
β β βββ provider.tf
β β βββ version.tf
β βββ dev
β β βββ README.md
β β βββ backend.tf
β β βββ main.tf
β β βββ output.tf
β β βββ provider.tf
β β βββ version.tf
β βββ prod
β β βββ README.md
β βββ stg
β βββ README.md
βββ modules π Modules for each service
βββ api_gateway
β βββ README.md
β βββ main.tf
β βββ output.tf
β βββ setting
β β βββ main.tf
β β βββ output.tf
β β βββ variable.tf
β βββ variables.tf
βββ ec2
β βββ README.md
β βββ main.tf
β βββ output.tf
β βββ variables.tf
βββ lambda
β βββ README.md
β βββ main.tf
β βββ output.tf
β βββ variable.tf
βββ rds
β βββ reader
β β βββ README.md
β βββ writer
β βββ README.md
β βββ main.tf
β βββ output.tf
β βββ variables.tf
βββ route53
β βββ README.md
β βββ main.tf
β βββ output.tf
β βββ variables.tf
βββ s3
β βββ README.md
β βββ bucket
β β βββ main.tf
β β βββ output.tf
β β βββ variables.tf
β βββ object
β βββ latest.zip
β βββ main.tf
β βββ output.tf
β βββ src
β β βββ latest.js
β βββ variables.tf
βββ vpc
βββ README.md
βββ main.tf
βββ output.tf
βββ variables.tf
The creation of the following resources, which are not managed by this repository, is required separately.
-
S3 Bucket for tfstate file
- Bucket name like
serverless-express-with-terraform-tfstate
- Bucket name like
-
Sercrets in Secrets Manager
- master_username
- master_password
- port
- database_name
- kms_key_id
- api_key
-
KMS Key for RDS If not already created, please use the following CLI command to create the key.
aws kms describe-key --key-id alias/aws/rds --region {region-name}
$ vim ~/.aws/credentials
# π Add the following
[serverless-express-with-terraform]
aws_access_key_id=xxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxx
