|
5 | 5 | </div>
|
6 | 6 |
|
7 | 7 |
|
8 |
| -## What is Stacks for Terraform? |
9 |
| - |
10 |
| -**Stacks** is a code pre-processor for Terraform. It implements a **sustainable scaling pattern**, **prevents drift** and **boilerplate**, all while **plugging into your already existing Terraform pipeline**. |
11 |
| - |
12 |
| -Stacks was initially presented at [SREcon23 Americas](https://www.usenix.org/conference/srecon23americas/presentation/bejarano). |
13 |
| - |
14 |
| -***Warning:** Stacks is under heavy development, many things may change.* |
15 |
| - |
16 |
| - |
17 |
| -## What is a "stack"? |
18 |
| - |
19 |
| -- A **stack** is a set of Terraform resources you want to deploy one or more times. |
20 |
| -- Each instance of a stack is a **layer**. A stack has one or more layers, hence, the name "stacks". |
21 |
| - |
22 |
| -### Example |
23 |
| - |
24 |
| -``` |
25 |
| -vpc/ |
26 |
| -│ |
27 |
| -├── base/ |
28 |
| -│ ├── vpc.tf |
29 |
| -│ └── subnets.tf |
30 |
| -│ |
31 |
| -├── layers/ |
32 |
| -│ ├── production/ |
33 |
| -│ │ └── layer.tfvars |
34 |
| -│ └── staging/ |
35 |
| -│ ├── layer.tfvars |
36 |
| -│ └── vpn.tf |
37 |
| -│ |
38 |
| -└── stack.tfvars |
39 |
| -``` |
40 |
| - |
41 |
| -- This is an example stack called `vpc`. |
42 |
| -- It contains a `base` folder, containing the common Terraform configuration scoped for all layers in this stack. |
43 |
| -- It contains a `layers` folder with two layers, one called `production` and one called `staging`. Layer directories contain layer-specific Terraform configuration. |
44 |
| -- Finally, it contains an optional `stack.tfvars` file, which defines variables global to all layers in the stack. These variables can be overriden at the layer level through a layer-specific `layer.tfvars`. |
45 |
| - |
46 |
| - |
47 |
| -## How does Stacks work? |
48 |
| - |
49 |
| -Stacks sits between you (the Terraform user) and Terraform. It's a **code pre-processor**. |
50 |
| -Here's an overview of Stacks inner workings: |
51 |
| - |
52 |
| -1. It takes your stack definitions (as shown above) |
53 |
| -1. For each layer: |
54 |
| - 1. Joins the `base` code with the layer-specific code |
55 |
| - 1. Applies a number of transformations |
56 |
| - 1. Injects some extra configuration |
57 |
| - 1. Bundles it up for Terraform to plan/apply on it |
58 |
| - |
59 |
| - |
60 |
| -## How to use Stacks? |
61 |
| - |
62 |
| -First, you need to put the Stacks code somewhere close to your stack definitions. |
63 |
| -Here's an example (not necessarily what we recommend): |
64 |
| - |
65 |
| -``` |
66 |
| -your-terraform-repository/ |
67 |
| -│ |
68 |
| -├── src/ # the contents of the `src` directory |
69 |
| -│ ├── helpers.py |
70 |
| -│ ├── postinit.py |
71 |
| -│ └── preinit.py |
72 |
| -│ |
73 |
| -├── environments/ # see the `example` directory on how to set this up |
74 |
| -│ ├── production/ |
75 |
| -│ │ ├── backend.tfvars |
76 |
| -│ │ └── environment.tfvars |
77 |
| -│ └── staging/ |
78 |
| -│ |
79 |
| -└── stacks/ # put your stack definitions here |
80 |
| - └── vpc/ # the `vpc` stack shown above |
81 |
| - ├── base/ |
82 |
| - │ ├── vpc.tf |
83 |
| - │ └── subnets.tf |
84 |
| - ├── layers/ |
85 |
| - │ ├── production/ |
86 |
| - │ │ └── layer.tfvars |
87 |
| - │ └── staging/ |
88 |
| - │ ├── layer.tfvars |
89 |
| - │ └── vpn.tf |
90 |
| - └── stack.tfvars |
91 |
| -``` |
92 |
| - |
93 |
| -You can find [another example here](example/stacks/example) with all the appropriate file contents. |
94 |
| - |
95 |
| -Then you need to run Stacks in the layer you want to apply: |
96 |
| -```bash |
97 |
| -cd stacks/vpc/layers/production |
98 |
| -python3 ../../../../src/preinit.py |
99 |
| -cd stacks.out # where the preinit output goes |
100 |
| -terraform init |
101 |
| -python3 ../../../../../src/postinit.py |
102 |
| -``` |
103 |
| - |
104 |
| -Now you're ready to run any further `terraform` commands in the `stacks.out` directory. |
105 |
| - |
106 |
| -***Note:** we recommend putting `stacks.out` in `.gitignore` to prevent it from being tracked by git.* |
| 8 | +## What is Stacks? |
| 9 | + |
| 10 | +**Stacks** is a [Terraform](https://www.terraform.io/) code pre-processor. |
| 11 | +Its primary goal is to minimize your total Terraform codebase without giving up on coverage. To do more with less. |
| 12 | + |
| 13 | +As a code pre-processor, Stacks receives your "input code" and returns "output code" for Terraform to consume. |
| 14 | + |
| 15 | +Stacks was originally developed and continues to be maintained by the Infrastructure SRE team at [Cisco ThousandEyes](https://www.thousandeyes.com/). |
| 16 | +It was initially presented and open-sourced at [SREcon23 Americas](https://www.usenix.org/conference/srecon23americas/presentation/bejarano). |
| 17 | + |
| 18 | +You can read "Terraform" and "OpenTofu" interchangeably, Stacks works with both but we've chosen to go with "Terraform" for readability. |
| 19 | + |
| 20 | +The ["I am starting from scratch" quick-start guide](<2.2. I am starting from scratch.md>) is a good introduction to Stacks and what it does. |
| 21 | + |
| 22 | + |
| 23 | +## Documentation |
| 24 | + |
| 25 | +1. About |
| 26 | + 1. [Considerations before using](<docs/1.1. Considerations before using.md>) |
| 27 | + 2. [Stacks vs. its alternatives](<docs/1.2. Stacks vs its alternatives.md>) |
| 28 | + |
| 29 | +2. Quick-start guide |
| 30 | + 1. [Installation instructions](<docs/2.1. Installation instructions.md>) |
| 31 | + 2. [I am starting from scratch](<docs/2.2. I am starting from scratch.md>) |
| 32 | + 3. [I am collaborating to an existing stack](<docs/2.3. I am collaborating to an existing stack.md>) |
| 33 | + 4. [I am collaborating to Stacks itself](<docs/2.4. I am collaborating to Stacks itself.md>) |
| 34 | + |
| 35 | +3. Reference |
| 36 | + 1. Native features |
| 37 | + 1. [Global Terraform code](<docs/3.1.1. Global Terraform code.md>) |
| 38 | + 2. [Reusable root modules](<docs/3.1.2. Reusable root modules.md>) |
| 39 | + 3. [Jinja templating for Terraform](<docs/3.1.3. Jinja templating for Terraform.md>) |
| 40 | + 4. [Jinja templating for variables](<docs/3.1.4. Jinja templating for variables.md>) |
| 41 | + 5. [Remote lookup functions](<docs/3.1.5. Remote lookup functions.md>) |
| 42 | + 6. [Inline secret encryption](<docs/3.1.6. Inline secret encryption.md>) |
| 43 | + 7. [Automatic variable initialization](<docs/3.1.7. Automatic variable initialization.md>) |
| 44 | + 2. Features you can build with Stacks |
| 45 | + 1. [Terraform state backend configuration](<docs/3.2.1. Terraform state backend configuration.md>) |
| 46 | + 2. [Terraform provider generation](<docs/3.2.2. Terraform provider generation.md>) |
| 47 | + 3. [Input validation](<docs/3.2.3. Input validation.md>) |
| 48 | + 3. Command-line interface |
| 49 | + 1. [`stacks render`](<docs/3.3.1. stacks render.md>) |
| 50 | + 2. [`stacks terraform`](<docs/3.3.2. stacks terraform.md>) |
| 51 | + 3. [`stacks diff`](<docs/3.3.3. stacks diff.md>) |
| 52 | + 4. [`stacks encrypt`](<docs/3.3.4. stacks encrypt.md>) |
| 53 | + 5. [`stacks decrypt`](<docs/3.3.5. stacks decrypt.md>) |
| 54 | + 6. [`stacks surgery list`](<docs/3.3.6. stacks surgery list.md>) |
| 55 | + 7. [`stacks surgery import`](<docs/3.3.7. stacks surgery import.md>) |
| 56 | + 8. [`stacks surgery remove`](<docs/3.3.8. stacks surgery remove.md>) |
| 57 | + 9. [`stacks surgery rename`](<docs/3.3.9. stacks surgery rename.md>) |
| 58 | + 10. [`stacks surgery move`](<docs/3.3.10. stacks surgery move.md>) |
| 59 | + 11. [`stacks surgery edit`](<docs/3.3.11. stacks surgery edit.md>) |
| 60 | + 4. [Directory structure](<docs/3.4. Directory structure.md>) |
| 61 | + 5. [Special variables](<docs/3.5. Special variables.md>) |
0 commit comments