Skip to content

michaelbrewer/url-shortener

Repository files navigation

url-shortener

Url Shortener Build CDK Build Code Coverage Code style: black Code style: ktlint Conventional Commits

URL Shortener AWS CDK example and using AWS Lambda Powertools for Python

High level infrastructure architecture

  • Route 53 - Is used to setup the dns records for the url shortener public endpoint
  • API Gateway Http Api - Is used to host shortener calls
  • AWS Certificate Manager - Is used to manage the wild card SSL cert
  • AWS Lambda - A Python 3.8 AWS Lambda function is used for both the creation of the shortened url but also the redirects
  • AWS DynamoDB - Used as the NoSQL database to store the shortened urls

URL Shortener Service Architecture

Building the Python Lambda

NOTE: Python 3.8+ is required

To install the required dev dependencies and run the unit tests. Run the following commands.

# Install the dev dependencies
make dev
# Build and run the unit tests
make pr

See IAC ReadMe for more details on how to deploy via AWS CDK

Tools used in this project

Design patterns and conventions

  • Conventional Commits - A specification for adding human and machine readable meaning to commit messages
  • The Twelve-Factor App - The Twelve-Factor App methodology is a methodology for building software-as-a-service applications. These best practices are designed to enable applications to be built with portability and resilience when deployed to the web.
  • Serverless Application Lens - Covers common serverless applications scenarios and identifies key elements to ensure that your workloads are architected according to best practices
  • DORA research program - DORA's State of DevOps research program represents six years of research and data from over 31,000 professionals worldwide

GitHub actions

General GitHub actions used by this project

Python AWS Lambda tools

Tools and libraries used for developing Python AWS Lambdas

  • Lambda Powertools - A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier
  • PipEnv - Python dependency management and manages virtualenv
  • PreCommit - A framework for managing and maintaining multi-language pre-commit hooks.
  • Flake8 - Python code style linting
  • Black - The uncompromising Python code formatter
  • iSort - Python utility to sort imports alphabetically, and automatically separated into sections and by type
  • Radon & Xenon - Various code metrics for Python code
  • MyPy - Optional Static Typing for Python
  • PyTest - Testing framework for Python
  • Moto - A library that allows you to easily mock out tests based on AWS infrastructure.

Infrastructure code tools

Tools and libraries used for building the infrastructure code

  • Gradle Versions Plugin - plugin provides a task to determine which dependencies have updates
  • AWS CDK - Define cloud infrastructure using familiar programming languages
  • Junit 5 - JUnit 5
  • JaCoCo - JaCoCo Java Code Coverage Library
  • KtLint - An anti-bikeshedding Kotlin linter with built-in formatter
  • Detekt - A static code analysis tool for the Kotlin programming language
  • CFNLint - Validate AWS CloudFormation yaml/json templates against the AWS CloudFormation Resource Specification
  • Serverless Rules - The Serverless Rules are a compilation of rules to validate infrastructure as code template against recommended practices
  • CFN-Diagram - CLI tool to visualise CloudFormation/SAM/CDK templates as diagrams
  • CDK Watchful - Construct library that makes it easy to monitor CDK apps

About

URL Shortener CDK example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published