/template-infra

A template to set up foundational infrastructure for your application in AWS

Primary LanguageHCLApache License 2.0Apache-2.0

Template repository for application infrastructure

Overview

This is a template repository to set up foundational infrastructure for your application in AWS. It is part of a collection of interoperable Platform templates.

This template includes setup for:

  • Team workflows - templates for pull requests (PRs), architecture decision records (ADRs), and Makefiles.
  • Account level foundational infrastructure - infrastructure for terraform backends, including an S3 bucket and DynamoDB table for storing and managing terraform state files.
  • Application infrastructure - the infrastructure you need to set up a basic web app, such as a image container repository, load balancer, web service, and database.
  • CI for infra - GitHub action that performs infra code checks, including linting, validation, and security compliance checks.
  • CD / Deployments - infrastructure for continuous deployment, including: AWS account access for Github actions, scripts for building and publishing release artifacts, and a Github action for automated deployments from the main branch.
  • Documentation - technical documentation for the decisions that went into all the defaults that come with the template.

The system architecture will look like this (see system architecture documentation for more information): System architecture

Application Requirements

This template assumes that you have an application to deploy. See application requirements for more information on what is needed to use the infrastructure template. If you're using one of the Platform application templates, these requirements are already met.

Installation

To get started using the infrastructure template on your project, run the following command in your project's directory to execute the download and install script, which clones the template repository, copies the template files to your repository, and removes any files that are only relevant to the template itself:

curl https://raw.githubusercontent.com/navapbc/template-infra/main/template-only-bin/download-and-install-template | bash -s

Now you're ready to set up the various pieces of your infrastructure.

Setup

After downloading and installing the template into your project:

  1. Follow the steps in infra/README.md to setup the infrastructure for your application.
  2. After setting up AWS resources, you can set up GitHub Actions workflows.
  3. After configuring GitHub Actions, you can set up continuous deployment.
  4. After setting up continuous deployment, you can optionally set up pull request environments
  5. At any point, set up your team workflow.

Updates

There are multiple ways to receive template updates on your project. For most updates, you can simply run the update-template script

curl https://raw.githubusercontent.com/navapbc/template-infra/main/template-only-bin/update-template | bash -s

If the update fails the simplest option may be to re-run the installation script above and manually review the changes.

Remember: Make sure to read the release notes in case there are breaking changes you need to address.

Renamed applications

If you renamed your application from infra/app to something else like infra/foo, then first rename your app back to infra/app before applying the updates e.g.

mv foo app
mv infra/foo infra/app
curl https://raw.githubusercontent.com/navapbc/template-infra/main/template-only-bin/update-template | bash -s
mv infra/app infra/foo
mv app foo