Infrastructure as Code with a Node Focus

Rate this content
Bookmark

This talk explores the power of tech infrastructure as code, allowing organizations to quickly, reliably and reproducibly build up, scale, and tear down real-world infrastructure as needed — with a focus on NodeJS stacks.

FAQ

Some recommended tools for implementing infrastructure as code include Chef, Puppet, SaltStack, Ansible, and Terraform. Terraform, in particular, is highlighted for its versatility and ability to work across multiple platforms.

G2I stands for 'good news to the Internet.' Its purpose is to help JavaScript and TypeScript engineers specializing in React, React Native, and Node find good work. It also assists companies in finding skilled engineers in these technologies.

Infrastructure as code is a method of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools.

Infrastructure as code allows for version control of your entire tech stack, enhances collaboration by making changes trackable and reversible, and increases the transparency of the infrastructure setup.

Terraform is a tool from HashiCorp that allows you to describe your infrastructure using a high-level configuration language. It provides a plan of changes to be applied to your infrastructure and updates only what is necessary to reach the desired state.

In the demonstration, AWS Lambda is used to host a NodeJS application that takes a screenshot of a given URL using Puppeteer, a headless Chrome instance, and returns the screenshot.

Serverless architecture, like AWS Lambda, only charges for the computing resources you use when your function is running. This can significantly reduce costs as you are not paying for idle server space.

Tejas Kumar
Tejas Kumar
36 min
24 Jun, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk discussed infrastructure as code using serverless Node.js with a focus on AWS Lambda and Terraform. The speaker emphasized the benefits of infrastructure as code, such as collaboration, versioning, and reproducibility. The Talk provided a step-by-step demonstration of deploying a Node.js app to AWS Lambda using Terraform. Key takeaways include the advantages of mechanized and automated processes, ephemeral state, repeatable processes, and transparency. The speaker also mentioned the importance of having DevOps experts on the team and highlighted the cost-effectiveness of serverless functions.

1. Introduction to Infrastructure as Code

Short description:

Today we're discussing infrastructure as code with a focus on serverless Node.js. Infrastructure encompasses all tech components, from servers and databases to gateways and CDN nodes. We'll use a lambda function as an example, exploring the need for a proxy or API gateway to ensure secure access. Disk read and write operations are also important considerations.

Hey, everyone. It's great to see you here at Node Congress. My name is Tejas. That's me. I'm working for G2I, stands for good news to the Internet. And really, what we do is we help JavaScript engineers or TypeScript engineers find good work, specializing in React, React Native, and Node. But we also help companies find JavaScript for TypeScript engineers specializing in React, React Native and Node. So it's kind of like Tinder but for Java.

Anyway, that's not why we're here. We are here today to talk about infrastructure as code with a focus on serverless Node.js. And you know, this is a hot topic. There's a bunch of talks coming up about this, like tomorrow Slobodin is talking about lambdas in the serverless architecture. And also Colin is talking about AWS CDK2 talks, I highly recommend. I think they're going to be amazing. I'm going to be looking out for them. And I'd encourage you if you like this talk, stick around for those.

But let's get started on this talk by defining the term infrastructure. What do we mean by infrastructure? Because it means different things to different people. What I mean for this talk is all of your tech stuff, your servers, your disks, your databases, your API, routers, your gateways, your load balancers through to your CDN nodes, which serve your static front ends probably. So everything. And let's maybe use an example. So say you have a lambda function. And it's just a function that does something, gives you an input, gives you an output. And at some point, somebody is going to want to interact with this function. And so they'll probably want to connect in some way. But allowing access directly to a function probably isn't the safest idea. So you might need some type of proxy or API gateway in front of it. So if the user talks to that thing, that thing then could talk to a load balancer or could talk to your function. And it's a bit safer. And then maybe your function needs to read or write to a disk.

2. Introduction to Infrastructure as Code (continued)

Short description:

But the API gateway shouldn't talk to the disk, because the user shouldn't talk directly to the disk. Traditionally, managing infrastructure was done through a graphical user interface or command line interface, which can be daunting and lacks collaboration and versioning capabilities. Infrastructure as code offers a better way, allowing you to describe your infrastructure in a text file that can be versioned and deployed as snapshots.

But the API gateway shouldn't talk to the disk, because the user shouldn't talk directly to the disk. So your architecture, your infrastructure can get a little bit complicated. That's just kind of normal. Things that are alive usually grow.

And traditionally, this stuff was managed by a cloud person or a DevOps person, or maybe many people. Maybe a team, even. But they would largely use a graphical user interface on the web of AWS or Azure or Google Cloud or Heroku or whatever. Or maybe a command line interface, but it's usually a largely manual process. And if we're being honest, this graphical user interface can be scary a bit sometimes.

And so, more than that, I believe the traditional way just has a few weak points. For example, it's not collaborative. If someone on the DevOps team changes the disk size from 8 gigs to 16 gigs on an EC2 instance, I don't know that it happened unless I ask them. And of course, with enough hacking around and creating audit logs, maybe, but by nature, like kind of out of the box, it isn't geared towards collaboration.

It can't be versioned. How cool would it be if I could have an infrastructure with a bunch of components and load balancers and things, and then I check that in Git and then I can time travel to it. I can even revert or commit a new version. You can't do that traditionally. It's largely manual. As we just saw, people would usually go in and change components or add new components or remove components by hand.

It's ultimately opaque. I've been a part of teams where I had no idea what the infrastructure looked like. I just didn't know. I pushed something and then it's deployed, but how? No idea. I feel by knowing this, we might facilitate higher-velocity software and so I believe there is a better way. I believe there's not just a better way, there is a sexy way. And that is infrastructure as code.

So you might be asking, how is this any sexier than traditional? Well, it's a version. So imagine a file, a text file, where it describes everything you have, from your load balancers, to your databases, to everything. It's a text file, it's a text file, it can be checked into Git versions. Secondly, when you deploy things, it creates a snapshot of the state of your infrastructure, and so if you want to change your disk from 8 gigs to 16, it can intelligently diff and find out change and update that component.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.
ESM Loaders: Enhancing Module Loading in Node.js
JSNation 2023JSNation 2023
22 min
ESM Loaders: Enhancing Module Loading in Node.js
Native ESM support for Node.js was a chance for the Node.js project to release official support for enhancing the module loading experience, to enable use cases such as on the fly transpilation, module stubbing, support for loading modules from HTTP, and monitoring.
While CommonJS has support for all this, it was never officially supported and was done by hacking into the Node.js runtime code. ESM has fixed all this. We will look at the architecture of ESM loading in Node.js, and discuss the loader API that supports enhancing it. We will also look into advanced features such as loader chaining and off thread execution.
Out of the Box Node.js Diagnostics
Node Congress 2022Node Congress 2022
34 min
Out of the Box Node.js Diagnostics
In the early years of Node.js, diagnostics and debugging were considerable pain points. Modern versions of Node have improved considerably in these areas. Features like async stack traces, heap snapshots, and CPU profiling no longer require third party modules or modifications to application source code. This talk explores the various diagnostic features that have recently been built into Node.
You can check the slides for Colin's talk here. 
Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Can Deno run apps and libraries authored for Node.js? What are the tradeoffs? How does it work? What’s next?
Multithreaded Logging with Pino
JSNation Live 2021JSNation Live 2021
19 min
Multithreaded Logging with Pino
Top Content
Almost every developer thinks that adding one more log line would not decrease the performance of their server... until logging becomes the biggest bottleneck for their systems! We created one of the fastest JSON loggers for Node.js: pino. One of our key decisions was to remove all "transport" to another process (or infrastructure): it reduced both CPU and memory consumption, removing any bottleneck from logging. However, this created friction and lowered the developer experience of using Pino and in-process transports is the most asked feature our user.In the upcoming version 7, we will solve this problem and increase throughput at the same time: we are introducing pino.transport() to start a worker thread that you can use to transfer your logs safely to other destinations, without sacrificing neither performance nor the developer experience.

Workshops on related topic

Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
GraphQL - From Zero to Hero in 3 hours
React Summit 2022React Summit 2022
164 min
GraphQL - From Zero to Hero in 3 hours
Workshop
Pawel Sawicki
Pawel Sawicki
How to build a fullstack GraphQL application (Postgres + NestJs + React) in the shortest time possible.
All beginnings are hard. Even harder than choosing the technology is often developing a suitable architecture. Especially when it comes to GraphQL.
In this workshop, you will get a variety of best practices that you would normally have to work through over a number of projects - all in just three hours.
If you've always wanted to participate in a hackathon to get something up and running in the shortest amount of time - then take an active part in this workshop, and participate in the thought processes of the trainer.
Mastering Node.js Test Runner
TestJS Summit 2023TestJS Summit 2023
78 min
Mastering Node.js Test Runner
Workshop
Marco Ippolito
Marco Ippolito
Node.js test runner is modern, fast, and doesn't require additional libraries, but understanding and using it well can be tricky. You will learn how to use Node.js test runner to its full potential. We'll show you how it compares to other tools, how to set it up, and how to run your tests effectively. During the workshop, we'll do exercises to help you get comfortable with filtering, using native assertions, running tests in parallel, using CLI, and more. We'll also talk about working with TypeScript, making custom reports, and code coverage.