A very simple Framework to manage your Infrastructure as Code.

CuongQuay
CuongQuay
Aug 16, 2020 · 4 min read

When working with AWS services, you’ve got several choices to build and deploy your lambda functions: Serverless Framework, AWS Amplify Framework, and AWS SAM CLI are the three most popular toolkit today. Each of them has different pros and cons. The cons you will get just happens after your project sized to be a complex solution beyond their pre-designed, intended purpose. In this article, I want to introduce yet another choice for your work with less locked-in, highly customization, and ultimate control of your Infrastructure as Code solution.

Figure — 1: A complex resource stack solution.

What is Simplify-SDK? This is a JavaScript SDK that helps your DevOp integration easier by adding deployment steps inline to your project solution. You will never want to be locked into any vendor for a tool you use. In FaaS architecture, a function can be very small but a project needs some (3–100) functions to orchestrate a workload. One CI/CD tool for all of them is quite hard to deploy your project when you just need to manage a stand-alone function.

According to this intention of purpose, Simplify-SDK is built for creating new infrastructure as AWS resources, managing Lambda functions and its configuration, monitoring them by writing your infrastructure management tool using your favourite JavaScript language with Node runtime. For a basic understanding of how to use this SDK, here is a “Hello World” example:

Given you have an existing Lambda function that was already deployed by a Serverless YML definition with the StackOutput parameters:

  • Lambda Function Name:
    — “YourLambdaFunction-1WDRZ5J5OUN5H”
  • Lambda Function Role ARN: — “arn:aws:iam::01234567890:role/YourLambdaExecutionRole”

Serverless organizes your code with a repo base concept with single Code Base, one Resource Stack and one Policy. Here is your project structure of a FaaS architecture organized within one repo:

Figure — 2: A typical serverless project structure.

There are two new files: config.json and deploy.js that do not belong to Serverless Framework and will be added in the next steps of this article.

After months of a project growing, you don’t want to update your function using command. One of your reasons will be serverless uploads your function code using a single distribution package with all repo code. The other hand, it uses one single AWS Role Policy per repo for every function. Instead of that design, you want to design a function by your way; with extended management capability — for example; you must restrict your function resource access with an individual Role Policy, you want to minimize your function code just deploy a partial code what they need to overcome Cold Start bootstrap issue, or to extend the other security measures etc, those things are hard to be done by just using Serverless Framework.

To do so, Simplify-SDK which is distributed as a node package must be installed by using npm or yarn as your choice (use one of them):

  • npm install simplify-sdk
  • yarn add simplify-sdk

To give the framework knowing about your deployment environment, a generic configuration is created to declare what you intend to do with your function and other resources. Here is an example of config.json:

In this configuration, it allows you passing variables from your code or ENVIRONMENT variables (ex: process.env.VAR) into the brackets syntax placeholders — ${VAR} that was declared in config.json. The Function block of this file is the parameter input following the definition of AWS Lambda updateFunctionCode:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionCode-property

Now, it’s time to write your infrastructure as NodeJS code:

You can find this example code at https://github.com/simplify-framework/simplify repository by README document.

Finally, to update your function code, just get into your function location and run this code:

cd functions/YourLambdaFunction && node deploy.js

Or adding this command line into your package.json:

Simplify-SDK supports these functions to manage AWS infrastructure such as creating your very complex CloudFormation stack, linking between serverless and another CloudFormation resource or managing AWS Resource Policy:

Checkout Simplify Framework for more than what you need!

Follows my articles:

Publishing a TensorFlow Model on AWS Lambda to make a sell-able API
DIY — Build Yourself a Serverless Framework with 152 Lines of Code
The On-Demand Wakeup Pattern to Overcome AWS Lambda Cold Start

Problem Solving Blog

Wicked problems have no stopping rule, as in there’s no way to know your solution is final.

CuongQuay

Written by

CuongQuay

(MSc) Cloud Security | Simplify Framework Creator | FinTech CTO | Technical Startup Booster (Consultant).

Problem Solving Blog

Albert Einstein has solved the problem of “time”, “light” and “space” by his curious thinking then answered by himself. In daily life, problems come every time and each person has their solution. By sharing your solution to people, you are contributing to creating the best idea.

CuongQuay

Written by

CuongQuay

(MSc) Cloud Security | Simplify Framework Creator | FinTech CTO | Technical Startup Booster (Consultant).

Problem Solving Blog

Albert Einstein has solved the problem of “time”, “light” and “space” by his curious thinking then answered by himself. In daily life, problems come every time and each person has their solution. By sharing your solution to people, you are contributing to creating the best idea.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store