Case Study - Infrastructure as Code & NextJS

Implementing: Infrastructure as Code using Terraform CDK in TypeScript, an integrated Typescript CLI and a NextJS-based Checkout Service

Client
etrainu
Year
Service
Architecture & Software Development

Overview

In response to etrainu’s burgeoning growth and the increasing demands on its online training platform, etrainu partnered with Stacktrace to embark on a new strategic project with four clear objectives:

  1. Support etrainu’s North American growth by expanding consumer-facing payment options for US higher-education and sporting club customers.
  2. Accelerate etrainu’s roadmap away from previous-gen technologies by providing a modern reference-application for replication as old services are retired and new engineers are welcomed to the etrainu team.
  3. Increase the security, robustness and reproducibility of per-region, per-customer infrastructure
  4. Support access to a broader local technical community for etrainu’s future recruitment

The First Piece of the Solution - a NextJS-based Checkout Service

After some collaborative technical design sessions and a rigorous evaluation of payment-processing alternatives, we identified an opportunity to address each of these objectives by delivering a new Checkout service, sitting as an intermediary between etrainu’s Learning Management System and its subscription management solution.

Introducing Stacktrace resources to the etrainu team

Our approach to team augmentation is flexible, and adapts to suit our clients' needs and the project at hand. In this instance, we communicated with etrainu’s team via Slack, worked within the existing AWS accounts and permissions hierarchy, and pushed directly to etrainu’s Gitlab for review and collaboration. We generally prefer to immerse ourselves entirely in our customers’ existing culture and project delivery processes to foster tight, frequent feedback loops and maximize efficiency.

Great CI/CD Means Infrastructure as Code (Terraform CDK in TypeScript)

As etrainu's business was expanding to include new large-scale international customers with in-region data sovereignty and isolation expectations, it became imperative to adopt a scalable, flexible, and repeatable infrastructure model.

From our analysis, Terraform CDK (TypeScript) emerged as the ideal tool, offering a blend of maturity, developer familiarity, and advanced CI/CD integration:

  • With many environments under management, the newer CDK option shone over and above Terraform’s traditional HCL alternative, where the required flexibility and reusability of components would have pushed the HCL-variant’s module and variable systems beyond their utility.
  • Staying inside TypeScript held useful advantages for integrating typesafe configuration outputs and secrets into deployment pipelines.

Critically, this choice began a theme of migration towards the TypeScript ecosystem, allowing etrainu to cross-train and cross-recruit TypeScript developers looking to apply their existing programming skills to infrastructure management reducing the need for specialization.

Scripts are brittle. Ship a CLI.

Over time, Stacktrace has made substantial investments in the tooling that supports the full software-development lifecycle from local hardware through continuous-integration, through to fully-automated and configured continuous-delivery. We were delighted to pass along the fruit of these investments in the delivery of etrainu’s Checkout application.

  • Every repo (and we encourage monorepo approaches under all but the most extreme circumstances) ships with an integrated TypeScript CLI (https://mael.dev/clipanion/), covering every phase of activity.
    • All terraform actions
    • All local development activities and local dependency management
    • Testing both locally and via CI
    • Secrets and configuration management for all environments
    • Deployment actions (e.g. triggering ECS/CodeDeploy SDKs with configuration from terraform outputs).
    • As an indication of completeness, most CLIs we ship offer 50-100 subcommands!
  • To the extent possible, all AWS, Azure and Buildkite resources are managed under Terraform
  • All deployment and infra auth is managed using AWS IAM + AWS Vault

We’re passionate about CI/CD at Stacktrace, so in the interest of brevity let’s just say that we believe that an end-to-end integrated approach to standardize and securely manage development, testing, infrastructure and deployments yields valuable productivity gains, and greatly mitigates the security risks associated with human-driven configuration.

The end result of this aspect of our project together is that even with many regional and customer-specific production environments, every application or infrastructure code commit triggers an automated build and test process, followed by a safe, predictable deployment. These in turn minimize manual effort and human errors, and accelerate deployment cycles.

Implementing these security best practices and compliance checks into the infrastructure provisioning process was rightly a priority for etrainu. The adoption of a project CLI and Terraform CDK together have delivered best-in-class auditability, supporting ambitious compliance objectives.

Why NextJs? Consistency and Community

It’s no surprise that within the Brisbane development community, there are many avid TypeScript and Next.js proponents. With TypeScript's static typing and Next.js's server-side rendering, automatic code splitting, and intuitive API routing system, both technologies enhance code readability, comprehension, and the ease of development.

We don’t believe NextJs is some magic technology that’s a fit for every situation, but we greatly value consistency, and the discipline it takes over time to keep a lean footprint in the face of such a rapidly evolving technology ecosystem. We hope that their new Checkout application will serve etrainu for many years to come, and act as a sensible jumping-off point for future UIs and REST APIs.

Migrating etrainu’s codebase to Next.js and TypeScript not only lays a robust technical foundation for future endeavors but also strategically aligns the company's tech stack with Brisbane’s React/Typescript talent pool. With greater access to local skills and expertise, we’re confident etrainu will remain at the forefront of web development innovation for many years to come.

What we did

  • Full-stack Development
  • AWS Infrastructure
  • Roadmap Acceleration
  • Terraform
  • CI/CD

Dan and the team from Stacktrace were amazing partners to work with and hit the mark on all of etrainu's objectives during our first engagement working together. We had heard great things in the Brisbane market about Stacktrace and were more than impressed with the multi layered solution, support and guidance Stacktrace delivered throughout the project. The team at Stacktrace provided thought leadership on all aspects of the project and were able to help embed new technologies, processes and tooling improvements into the platform and team here at etrainu.

Martin Knott
CTO - etrainu
Infrastructure Automation
Terraform
CLI
Clipanion
Development Framework
NextJs
Language
TypeScript

More case studies

Secure Australian Generative AI

Driven by the success of OpenAI's ChatGPT, Australian businesses are increasingly looking for a secure, privacy-first way to test-drive generative AI.

Read more

Digital Paediatrics

Cub Care is the world's first paediatrics-specific software and data science platform, built and designed by Stacktrace in collaboration with Cub Care clinicians from the ground up.

Read more

We’d love to accelerate your next project.

Our offices

  • Brisbane
    L2, 303 Coronation Drive
    4064, Brisbane, Australia