How to Write a Rulebook?

Rule Books are how you teach Stakpak to follow your way of doing things. In this tutorial, we will learn how to create our own rule books:

Create a Rule Book from the Website

  1. Go to stakpak.dev and sign in

  2. On the left tab choose rule books and then press "Create Rule Books"

  1. Here all the magic happens

    1. URI: The unique link or path where the agent fetches and runs your rule book.

    2. Public: You can share the URI of your rule book, and other people will be able to use it Private: Only you will have access to the rule book

    3. Description: Write a description for the rule book

    4. Tags: Add tags the agent uses to decide when to pull the rule book.

    5. Content: Add the main content of your rule book here. It's just a simple Markdown file.

  2. That's it, press "Create Rule Book"

Create a Rule Book from the CLI

  1. Create a new Markdown file using this template:

---
uri: stakpak://my-org/deployment-guide.md
description: Standard deployment procedures for production
tags:
  - deployment
  - production
  - sop
---

# Deployment Guide

Your deployment procedures and guidelines here...
  1. Open your terminal.

  2. Navigate to the directory where the file is saved.

  3. Run the following command to create/update the Rule Book:

stakpak rb apply rulebook-name.md
  1. To delete an existing Rule Book, run:

stakpak rb delete stakpak://my-org/old-guide.md

Tips for Writing Stakpak Rule Books?

  • Use a clear structure

  • Describe what needs to be automated rather than giving manual step by step instructions.

  • You can add requirements

    • Only run if there is Terraform code, for example

  • You can ask it to follow certain standards and guidelines

    • Principle of least privilege

    • OWASP Guidelines

    • AWS Well Architected Framework

    • Or even your internal company guidelines

  • Add references

Last updated