# aws-code-habits **Repository Path**: mirrors_awslabs/aws-code-habits ## Basic Information - **Project Name**: aws-code-habits - **Description**: A library with Make targets, Ansible playbooks, Jinja templates (and more) designed to boost common software development tasks and enhance governance. - **Primary Language**: Unknown - **License**: MIT-0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-10-27 - **Last Updated**: 2026-03-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![logo][logo] [![Test](https://github.com/awslabs/aws-code-habits/actions/workflows/test.yaml/badge.svg)](https://github.com/awslabs/aws-code-habits/actions/workflows/test.yaml)[![GitHub Issues](https://img.shields.io/github/issues/awslabs/aws-code-habits)](https://github.com/awslabs/aws-code-habits/issues)[![GitHub Stars](https://img.shields.io/github/stars/awslabs/aws-code-habits)](https://github.com/awslabs/aws-code-habits/stargazers)[![hygiene](https://github.com/awslabs/aws-code-habits/actions/workflows/hygiene.yaml/badge.svg)](https://github.com/awslabs/aws-code-habits/actions/workflows/hygiene.yaml) # AWS Code Habits A library with Make targets, Ansible playbooks, Jinja templates (and more) designed to boost common software development tasks and enhance governance. | ![screenshot-1](https://user-images.githubusercontent.com/3298422/198290134-fec4a14d-8542-4b92-9cbc-d33f476e7a74.gif) | |:--:| | *Installing AWS Code Habits* | ## Table of Contents - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Usage](#usage) - [How-Tos](#how-tos) - [How to initialize pre-commit config](#how-to-initialize-pre-commit-config) - [How to maintain documentation](#how-to-maintain-documentation) - [How to expand Habits commands](#how-to-expand-habits-commands) - [How to use technology-specific Makefiles](#how-to-use-technology-specific-makefiles) - [Testing](#testing) ## Getting Started AWS Code Habits was developed to be used as a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). On a terminal, on your project's root directory, execute one of the following commands: ```bash git submodule add --name habits -b main https://github.com/awslabs/aws-code-habits.git habits ``` This will clone AWS Code Habits on a folder named `habits` and track against the `main` branch. Now, you will need to create, or add to your existing, `Makefile`. ```bash export WORKSPACE=$(shell pwd) export HABITS = $(WORKSPACE)/habits include $(WORKSPACE)/tools.env # pin the version of your tools include $(HABITS)/lib/make/*/*.mk include $(HABITS)/lib/make/*.mk ``` Remember, next time you need to clone your repository, you will need to include `--recurse-submodules` parameters. ```bash git clone --recurse-submodules ... ``` > If you already cloned the project and forgot `--recurse-submodules`, you can combine the `git submodule init` and `git submodule update` steps by running `git submodule update --init`. To also initialize, fetch and checkout any nested submodules, you can use the foolproof `git submodule update --init --recursive`. - [Git Tools Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) Check the [scripts](scripts/) directory, if you want to automate the initialization and installation of AWS Code Habits.` ## Prerequisites A list of things you need, or how to install them. > AWS Code Habits now supports multiple platforms including Linux, macOS, and Windows (with some limitations). Many Makefiles include cross-platform detection and appropriate installation methods. - [Python 3](https://www.python.org) - Whether you're new to programming or an experienced developer, it's easy to learn and use Python. - [Pip](https://pypi.org/project/pip/) - pip is the package installer for Python. - [GNU Make](https://www.gnu.org/software/make/) - GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. ## Usage ```bash make [tab][tab] ``` ```bash make help ``` For more information about each [Make targets available](Makefile.md). Each technology-specific Makefile includes its own help target. For example: ```bash make terraform/help make nodejs/help make python/help make go/help make gitignore/help ``` ## How-Tos Below you can learn ### How to initialize pre-commit config ```bash make pre-commit/init ``` To run all `pre-commit` rules in all files, simply run: ```bash make pre-commit/run ``` ### How to maintain documentation 1. First initialize all documentation files: ```bash make doc/init ``` This will create a folder named `doc/` in the root directory of your project and create a file named `habits.yaml` inside of it. 2. Modify the contents of `doc/habits.yaml` accordingly and execute: ``` make doc/build ``` 3. `README.md` will be rendered. ### How to expand Habits commands You can use [Habits][habits] to meet your needs, in your `Makefile` you can add the following to ensure code and documentation hygiene: ```bash .PHONY: hygiene hygiene: doc/build pre-commit/run ``` Another example, if you want to perform several tasks with `AWS CloudFormation`: ```bash .PHONY: hygiene hygiene: aws/cloudformation/hygiene .PHONY: plan plan: aws/cloudformation/create-change-set .PHONY: discard discard: aws/cloudformation/delete-change-set .PHONY: apply apply: aws/cloudformation/execute-change-set ``` ### How to use technology-specific Makefiles AWS Code Habits includes several technology-specific Makefiles that provide targets for common development tasks: ### Terraform ```bash # Install Terraform make terraform/install # Initialize Terraform make terraform/init # Plan changes make terraform/plan # Apply changes make terraform/apply # Manage workspaces make terraform/workspace/list make terraform/workspace/new WORKSPACE_NAME=dev ``` ### AWS CDK ```bash # Install AWS CDK make aws/cdk/install # Bootstrap CDK environment make aws/cdk/bootstrap # Deploy CDK stack make aws/cdk/deploy # Synthesize CloudFormation template make aws/cdk/synth ``` ### Python ```bash # Install Python make python/install # Initialize virtual environment make python/virtualenv/init # Set up Poetry make python/poetry/install make python/poetry/init # Run tests make python/test ``` ### Node.js ```bash # Install Node.js make nodejs/install # Initialize projects make nodejs/init/express make nodejs/init/react make nodejs/init/vue # Package management make nodejs/add PACKAGE=express make nodejs/add/dev PACKAGE=jest ``` ### Go ```bash # Install Go make go/install # Build application make go/app/build OUTPUT=myapp # Run tests make go/app/test ``` ### Gitignore ```bash # Initialize gitignore for specific project types make gitignore/init/web make gitignore/init/python make gitignore/init/node ``` ## Testing To perform habits checks: ```bash make habits/check ``` Each technology-specific Makefile includes its own testing targets. For example: ```bash # Run Python tests make python/test make python/test/coverage # Run Node.js tests make nodejs/test # Run Go tests make go/app/test make go/app/test/coverage ``` ## References - [GNU Make](https://www.gnu.org/software/make/) - GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. - [Windows Subsystem for Linux (Ubuntu)](https://docs.microsoft.com/en-us/windows/wsl/install) - WSL enables you to use Linux tools, like Bash or Grep, completely integrated with Windows tools, like PowerShell or Visual Studio Code, with no need to dual-boot. - [Visual Studio Code](https://code.visualstudio.com/) - Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. - [VSCode Remote Development Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) - An extension pack that lets you open any folder in a container, on a remote machine, or in WSL and take advantage of VS Code's full feature set. - [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) - Submodules allow you to keep a Git repository as a subdirectory of another Git repository. - [Docker](https://www.docker.com/products/docker-desktop/) - The fastest way to containerize applications - [Visual Studio DevContainers](https://code.visualstudio.com/docs/devcontainers/containers) - The Visual Studio Code Dev Containers extension lets you use a Docker container as a full-featured development environment. - [Ansible](https://www.ansible.com/) - Ansible is an open source community project sponsored by Red Hat, it's the simplest way to automate IT. - [Jinja2](https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html) - Ansible uses Jinja2 templating to enable dynamic expressions and access to variables and facts. - [Terraform](https://www.terraform.io/) - Terraform is an infrastructure as code tool that lets you build, change, and version infrastructure safely and efficiently. - [AWS CDK](https://aws.amazon.com/cdk/) - The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through AWS CloudFormation. - [Python](https://www.python.org/) - Python is a programming language that lets you work quickly and integrate systems more effectively. - [Node.js](https://nodejs.org/) - Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. - [Go](https://golang.org/) - Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. ## License This project is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file. ## Copyright Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. [repo]: https://github.com/awslabs/aws-code-habits [logo]: doc/logo.png [habits]: https://github.com/awslabs/aws-code-habits