Skip to content

vzsoares/shortener

Repository files navigation

Shortener

GitHub watchers GitHub forks GitHub stars GitHub release GitHub license Connect on linkedin

Deploy your own shortener service in the aws free tier. Made in Go with minimal dependencies. Raw HTML JS and tailwind front. Main engine to integrate with other internal services.

Features 🚀

  • Fully serverless pay per request
  • Terraform infra
  • Github actions
  • Generic main engine
    • Easily integrate using a api-key
  • Bff implementation example

Requirements 🛠️

  • make
  • aws-cli
  • terraform
  • go
  • node
  • yarn

Setup 🦩

Make sure to have all requirements.

local:

  1. Clone the repo
  2. Install node dependencies with yarn install
  3. Copy .env.example to .env.dev and .env.prod and fill the values

    Some values only exist after running Terraform apply

  4. configure aws credentials
  5. Configure your runner in nx.json tasksRunnerOptions
  6. ⚠️Configure the Terraform provider backend by changing or removing the provider.tf backend section in each environment
  7. export AWS_PROFILE={your-profile}
  8. Deploy once with nx run shortener:first-deploy:dev and nx run shortener:first-deploy:prod
  9. Get the cloudfront distribution id and put it on your envs
  10. Finally deploy with nx run shortener:deploy:dev and nx run shortener:deploy:prod

github actions:

  • configure a prod and dev environment with:
    • secrets:
      • AWS_ACCESS_KEY_ID
      • AWS_PROFILE
      • AWS_REGION
      • AWS_SECRET_ACCESS_KEY
    • variables:

      same as .env

      • API_BASE_URL
      • API_BASE_URL_DOMAIN
      • ARTIFACTS_BUCKET_NAME
      • DYNAMO_URL_TABLE_NAME
      • FRONT_BASE_URL
      • FRONT_BASE_URL_DOMAIN
      • FRONT_BUCKET_NAME
      • FRONT_CLOUDFRONT_DISTRIBUTION_ID
      • GATEWAY_API_NAME
      • NX_RUNNER
      • STAGE

Usage ☃️

See all available commands bellow and use with: nx run {project}:{task}:{environment}. Ex: nx run engine:serve:dev to start a local api.

Projects Tasks
engine build, lint, serve, test, tidy
front build, lint, publish, serve, test, tidy
public-api build, lint, serve, test, tidy
utils lint, test, tidy
shortener deploy, first-deploy

Architecture 🎨

See in /docs

deployment sequence
entity usecase
swagger_p swagger_e

About

URL Shortener - Go - AWS Free tier - Terraform | Lambda DynamoDB S3

Topics

Resources

License

Stars

Watchers

Forks