Skip to content

RiskyFrisky/DevTestProdAWS

Repository files navigation

DevTestProdAWS

Main Branch

unit-test integration-test deploy

Dev Branch

unit-test integration-test

This project was used as a learning tool to figure out how to develop a production-grade CI / CD workflow that would minimize the risk of publishing bad code into production AWS environments.

Access application frontend: https://riskyfrisky.github.io/DevTestProdAWS

Steps for running on your PC

Pre-requisites

  1. Bun: https://bun.sh/docs/installation
  2. Tools for deploying on LocalStack
  3. Tools for deploying on AWS

Setup

bun i

cd $(git rev-parse --show-toplevel)/Lambda/Layer/nodejs
bun i

Unit Test

cd $(git rev-parse --show-toplevel)/Lambda/__test__/unit
bun test

Build

cd $(git rev-parse --show-toplevel)/Lambda/Layer/nodejs
bun run compile

cd $(git rev-parse --show-toplevel)/Cloudformation
samlocal build --template-file template.yaml
or
sam build --template-file template.yaml

Deploy on LocalStack (Requires PRO account for LambdaLayer use)

cd $(git rev-parse --show-toplevel)/Lambda/__test__/integration/localstack
docker compose --env-file $(git rev-parse --show-toplevel)/.env up

awslocal s3 mb s3://devtestprodaws

cd $(git rev-parse --show-toplevel)/Cloudformation
samlocal deploy --config-file samconfig.toml --capabilities CAPABILITY_NAMED_IAM --no-confirm-changeset
  • Integration test

    export FUNCTION_URL=$(awslocal lambda list-function-url-configs --function-name devtestprodaws-main | grep -o '"FunctionUrl": "[^"]*' | awk -F'"' '{print $4}')
    
    cd $(git rev-parse --show-toplevel)/Lambda/__test__/integration
    bun test

Deploy on AWS

  • Create a unique bucket name in AWS cloud first (e.g. devtestprodaws-2) & update samconfig.toml s3_bucket value
cd $(git rev-parse --show-toplevel)/Cloudformation
sam deploy --config-file samconfig.toml --capabilities CAPABILITY_NAMED_IAM --no-confirm-changeset

Test GitHub actions locally

Test action locally with act

gh act --secret-file .env --job unit-test-job
gh act --secret-file .env --job integration-test-job
gh act --job deploy-job

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published