/shortify

A personal url shortener deployed on AWS.

Primary LanguageHCLMIT LicenseMIT

Shortify - a personal url shortener

Shortify is a 100% cloud based URL shortener service which makes it simple to remember long- and hard-to-reach URLs.

The entire service is deployed on AWS using Terraform and uses different AWS services such as API Gateway, AWS Lambda and DynamoDB.

Table Of Contents

Background

This project was inspired by goalie-url-shortener, which in turn is inspired by the go/ services deployed by companies such as Google. These services are used by these companies internally as a way to shorten otherwise hard to remember URLs. E.g. go/payroll would redirect to the payroll page.

What I wanted initially was to deploy such a service for personal use. There are other repositories on Github that offer such a service, however all of them are made to be deployed to servers.

Given my usage, having a VM always running would be too expensive compared to the value it provides. Enter serverless functions and AWS Lambda. With it's pay-for-what-you-use model, it fits my use case perfectly. I can have an always-ready service running and paying only when I use it.

Description

The entire infrastructure is documented in code using IaC tool Terraform. API Gateway is used to expose endpoints that will result in Lambda function invocations. The lambda functions will then query the DynamoDB database for the desired shortcut, and redirect the user there.

An S3 bucket and another DynamoDB table will also be used as a remote backend to maintain the terraform state.

So in total the following AWS services are used (almost all of these have free tier offerings):

  • API Gateway
  • 2x Lambda functions
  • 2x DynamoDB tables
  • 1x S3 bucket

Installation

Requirements

  • Terraform

  • AWS account credentials setup either as environment variables or in credentials file. Read more here.

Steps

  1. Initialize terraform

    $ terraform init
    
  2. Deploy the infrastructure. When this command finishes running, it will output a link where API requests can be sent. See here if you want the API to be accessible via a custom domain.

    $ terraform apply
    

Related

Shortify-Alfred

Shortify - Alfred is an integration/workflow for Alfred 3. Alfred is a MacOS productivity tool similar to Spotlight. Shortcuts in Shortify can be accessed by entering Ctrl + Space and then entering sh . It will list all saved shortcuts and allow you to fuzzy-search them. See installation steps here.