1.0.0 • Published 3 years ago

slm_cdk v1.0.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
3 years ago

This project is where we write, manage and deploy our cloud resources such as Lambdas, Databases, etc. The project is based on AWS CDK and is written in Typescript. Certain parts of the business logic may eventually be written in other languages like Python, Go, etc.

Project Dependencies

To run this project on your machine, you need to set up a few things:

NodeJS

NodeJS and NPM are at the core of our project, as most of our dependencies and code are dependendent on them. NPM comes bundled with NodeJS, so just visiting the NPM page and installing Node should get you going! Make sure you get version 10.15.3 or higher (only LTS versions).

AWS CLI

The AWS CLI allows you to interact with AWS services during deployment, monitoring, etc. You can either run pip install awscli (only on Mac), or install it manually by going following the instructions on the official page.

Typescript

The entire repo is written in Typescript. You can install it by running npm install -g typescript in your terminal.

AWS CDK

The central piece of the repo. The CDK is what allows us to easily define and automate our infrastructure, defining our resources and the relationships between them. To install it, open your terminal and run npm install -g aws-cdk.

Project & Structure

index.ts

Our index file is where we ultimately use all of our Stack code to instantiate our resources and bundle them together by extending the Stack class and instantiating a new stack.

/src

This is the location of our actual business logic, meaning the code that we actually deploy to the cloud and run as our application. Here is where we define things like Lambdas & Layers, Apps that wil run in containers, etc.

/src/lambda

This is where our lambdas code is located along with the unit tests that belong to it, divided in subfolders categorized by service (familySharing, Payway, Klarna, etc).

/src/layers

The code and unit tests for our lambda layers.

/src/localPackages

This folder contains our own custom modules, often containing tasks that need to be accessible in multiple places (think of fetching a user's token from Payway). Logging and Mocking tools and our custom Typescript Types also live in this folder. When updated or created, these folders should be "npm installed" into the repo source as well as the place where they will be used in the code (a layer, container, etc).

/Stack

The location where the different components of our infrastructure are located. This is where we define the resources we want to deploy and connect them together. The folder is mainly based on Constructs that instantiate resources and Services that provide the instructions on how to instantiate them.

/stack/Services

Services are simply objects belonging to a specific area of our product (FamilySharing, for example). These objects do nothing but hold configuration data that is serve as instructions to our Constructs at the time of building and deploying our stack.

/stack/Constructs

Constructs are classes that instantiate a specific type of resource. It could be an instance of apiGateway or a group of Lambda functions. Put in a simple way, a Construct will build up it's group of resources depending on the configurations provided to it by our different Services.

/Tooling

Location of scripts for automation and abstraction of complex, repetitive tasks like correctly creating a new lambda, for example. These tools are there to A) save us time and B) reduce the chance for human mistakes like typos, misplacement of files, etc.