Skip to content
/ tetris_aws Public template

Fullstack serverless template: Kotlin/Smithy/Lambda/APIGateway/React/CDK/Cognito

Notifications You must be signed in to change notification settings

zfz7/tetris_aws

Repository files navigation

tetris_aws

Goals

The goal of this project was to create a full stack AWS native project template. The secondary goal is to keep the DTO types in sync between the frontend and backend using code generation. Here is the achieved stack:

Warnings

The kotlin and typescript type generation rely on smithy-kotlin and smithy-typescript, both products are not yet GA. As such they still have some quirks to work through. Overall it seems that the typescript code generation tool is a bit more stable.

If you stumbled across this guide another resource that wasn't GA but looks promising is: aws-prototyping-sdk, specifically the type-safe-api.

^last updated 08/06/2023

Getting started

Prerequisites

This project assumes the following are installed on your system:

Setup

  1. Clone the repo: git clone git@github.com:zfz7/tetris_aws.git
  2. Export the following variables:
export AWS_PROFILE=AdministratorAccess-123456789012
export AWS_ACCOUNT=123456789012
export ROOT_HOSTED_ZONE_ID=ABCDEFGHIJKLIMOP
export ROOT_HOSTED_ZONE_NAME=example.com
  1. Build the project (from root): ./gradle build
  2. Login to AWS: aws sso login
  3. Deploy the project (from root): ./gradle deploy

Other Commands

###Clean 
./gradlew clean #clean all projects
./gradlew <project>:clean 
./gradlew backend:clean 
###Build 
./gradlew build #build all projects
./gradlew <project>:clean 
./gradlew model:build
###Deploy 
./gradlew deploy

###Testing the endpoint with Cognito
export C_TOKEN="$(aws cognito-idp initiate-auth --region us-west-2 --auth-flow USER_PASSWORD_AUTH --client-id <YOUR_CLIENT_ID> --auth-parameters USERNAME=<USERNAME>,PASSWORD=<PASSWORD> | jq -r .AuthenticationResult.IdToken)"'
curl -H "Authorization: Bearer $C_TOKEN" https://api.daniel-eichman.com/hello\?name\=hi