Skip to content

whatisusername/toon-tank-user-service

Repository files navigation

CI Go Version

User Service

This service manages user sign-up/sign-in functionality and returns an access token to the client. It integrates seamlessly with AWS Secrets Manager and Cognito for secure authentication.

The service is packaged as a Docker image and pushed to Amazon ECR. A Lambda Function is deployed using the container image. CI/CD is implemented via GitHub Actions, which automatically runs test jobs upon creating a pull request. To deploy the service, trigger the GitHub Action job titled 'Deploy to AWS'.

Installation

This service can be run locally using Docker or deployed to AWS using Terraform. Follow the installation steps below based on your preferred environment.

Mock

Document

go install github.com/vektra/mockery/v2@v2.50.4

make

  • Download mingw64

  • Extract files under C:\Program Files

  • Add C:\Program Files\mingw64\bin to the system's environment variable Path

  • Rename the executable under the bin folder from mingw32-make to make

  • Verify the installation by running the following command in the Command Prompt:

    make -v

Docker

Terraform

  • Download Terraform

  • Extract the downloaded file to C:\Program Files\HashiCorp\Terraform

  • Add the Terraform directory to your system's Path in the Environment Variables.

  • Verify the installation by running the following command in the Command Prompt:

    terraform version

(Optional) AWS

If you want to locally test the Docker image that is built for the Lambda Function.

Build Docker Image

make build

Run the Docker Image Locally

make local_run

Test the API Locally

  • Sign Up
curl "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"version":"2.0","path":"/v1/users","httpMethod":"POST","body":"{\"username\":\"<username>\",\"email\":\"<email>\",\"password\":\"<password>\"}","isBase64Encoded":false}'

Deploy the Lambda Function

Use the make command to deploy the service to your desired environment:

  • Replace ENV=dev with your target environment, e.g., dev, stag, prod.
  • Ensure that your AWS credentials are properly configured before deployment.
make tf_init ENV=dev
make tf_plan
make tf_deploy