Used AWS services:
- AWS Gateway: API backend resource
- DNS: Use external DNS / HTTPS configuration
- S3 Buckets: Define thumb and image file
- Dynamo: Database
Following packages are used in development environment:
- localstack
- node8 & npm 6
- git
- Terraform
- VisualStudio Code
Installation steps
- Make sure external development dependencies are installed (see above)
- Clone this repo if not yet done
- Setup AWS credentials account by using profiled accounts: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
- Add profiled account to
main.tf
shared_credentials_file = "~/.aws/credentials"
profile = "aws-rekognition-backend"
- Setup terraform workspaces for
local, dev, test
by using theterraform workspace create {worskpace-name}
command (replace workspace-name with local, dev or test). - Setup terraform.env files for each environment (naming schema: terraform.{your-environemnt-name}.tfvars) by clone / rename the
terraform.environment.example.tfvars
file. Note: All empty settings must be set in your used environment files. - Init terraform by calling:
terraform init
. - Apply dev environment on AWS by calling
npm run apply-dev
. - As soon as dev enrionment is loaded, open newly created lambda function in AWS web console and navigate down to environment section.
- In graphql-server, copy
.env.example
to.env
and copy / paste content fromDYNAMODB_TABLE_NAMES
andS3_BUCKET_NAMES
from AWS console into.env
file. - Add AWS user credentials to
.env
. Make sure you credentials are allowed to useS3
andRekognition
. - Cd into
graphql-server
and install dependencies:npm install
as your last step.
- Open whole project in Visual Studio Code.
- Open
main.tf
and comment out all "disable on local" flagged modules and enable "enable on local" modules instead. - Start localstack:
localstack start
- Apply environment locally by calling:
npm run apply-local
. - Init basic user with
. init-localstack.sh
. - Start graphql server (in case of issue at first start, restart build process again):
npm start
- Open
localhost:4000
to load GraphQL playground - Change any file and server will reload with
nodemon
.
Deployment is only supported by using Terraform. Please use multiple terraform workspaces for each AWS environment (during installation three default environments are pre-installed / supported). Due dependencies between sharp js
and your used OS, this project must be builded by using the appropriate AWS Dockerfile image.
Before release, make sure you're not exposing any credentials and replace choose a valid "APP_SECRET" for your JWT token in the .env
file.
- In
main.tf
make sure all "disabled on local" modules are enabled and all "enable on local" modules are disabled. - Check if Terraform is init correctly by calling:
terraform init
. - Stop local graphql-server development process, if running.
- Ensure Docker is installed and Docker process is running.
- Cd into root directory and start deployment build process by executing:
make all
. - After build process is finished (may take a while), deploy to your target environment:
npm run apply-{enviroment}
(replace environment with your target).