A self-documenting repository/website demonstrating tools and practices for developing higher-quality "as code" with a fast feedback cycle.
See it live at DoBetterAsCode.com.
Ensure you have Docker installed and running. You will also need a Java installation to use the batect task runner.
To configure the pre-commit hooks, install the therapist python module and run
therapist install in the cloned repository.
The "infra" folder is divided into "modules" of Terraform code, and the "project" which ties the modules together to create our static site hosted on AWS S3 with CloudFront.
The "app" folder contains a Hugo site which is compiled to HTML/CSS and pushed to S3.
The ".batect" folder contains Docker container defintions used for running tasks.
The ".circleci" folder contains our pipeline as code.
The following local validation tasks may be run from batect:
terraform-tflint - runs tflint to ensure our Terraform modules have valid syntax and match the AWS validation rules provided by AWS SDK
pipeline-validate - runs circleci-cli to make sure our CircleCI pipeline as code is valid
yaml-lint - runs yamllint to ensure all our yaml files are well formed
shell-lint - runs shellcheck to check the syntax of our bash scripts and warn of possible bugs
terraform-local-apply - runs a terraform apply against an AWS mock powered by localstack
localstack limitations mean we are only able to test our S3 module at this point in time
Tests for our infrastructure modules are located in
These tests use kitchen-terraform and awspec to create resources in AWS and then verify that the resources exist and meet our requirements.
terraform-integration-test task runs the full suite of tests.
You can specify an individual test to run by providing the name to batect (e.g.
./batect terraform-integration-test -- certificate)
The pre-commit hooks powered by Therapist will run all relevant validation tasks based on the files you are changing/committing.