-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e0491f
commit 15e2852
Showing
73 changed files
with
2,169 additions
and
811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Python | ||
__pycache__ | ||
|
||
# uv | ||
.python-version | ||
.venv | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Considerations before using | ||
|
||
## Stacks is designed for monorepos | ||
|
||
Stacks is primarily designed to be used in Terraform monorepos. | ||
|
||
We define a Terraform monorepo as a single version control repository whose code maps to two or more Terraform states. | ||
You can have multiple Terraform monorepos as long as they all map to more than one state each. | ||
|
||
While perfectly possible to use in "1 repository = 1 state" setups, Stacks shines brightest when "1 repository = N states". | ||
|
||
If your setup is not monorepo-like, we do not recommend you use Stacks. | ||
|
||
## Not all Terraform automation tools support pre-processors like Stacks | ||
|
||
Stacks was originally developed to run on top of [Atlantis](https://www.runatlantis.io/). | ||
Atlantis does support code pre-processors in the form of [pre-workflow hooks](https://www.runatlantis.io/docs/pre-workflow-hooks.html#pre-workflow-hooks). | ||
|
||
Unfortunately, not all Terraform automation tools are flexible enough for you to run a thing that will modify your checked-out code before Terraform consumes it. | ||
|
||
Same restrictions apply to any code scanning tools you may be using. You'll have to put Stacks before them, which may not be possible depending on what continuous integration platform they're running on. | ||
|
||
If your Terraform automation pipeline does not support such code pre-processors, you cannot use Stacks. | ||
|
||
## You will not be able to use code formatters like `terraform fmt` | ||
|
||
Since not all Stacks' input code is valid HCL, formatters like `terraform fmt` will not work. | ||
|
||
You can still use code formatters in output code, but since its not meant to be persisted anywhere there's little to no reason to do that either. | ||
|
||
If format enforcing through code formatters is something you're not willing to give up, you cannot use Stacks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Stacks vs. its alternatives | ||
|
||
## Stacks vs. Terraform workspaces | ||
|
||
A Stacks stack is a Terraform root module which you can deploy as many times as you have layers. | ||
|
||
Terraform CLI [workspaces](https://developer.hashicorp.com/terraform/language/state/workspaces) let you deploy the same root module as many times as you have workspaces. | ||
|
||
Both allow you to inject different input variable values on different layers or workspaces, respectively. | ||
|
||
So it would seem like both are similar, however, the primary goal of Terraform workspaces is to [enable testing changes](https://developer.hashicorp.com/terraform/cli/workspaces#use-cases) on a separate state before modifying production infrastructure, and HashiCorp [explicitly recommends against](https://developer.hashicorp.com/terraform/cli/workspaces#when-not-to-use-multiple-workspaces) using workspaces for long-lived parallel deployments of the same root module. | ||
|
||
_HCP Terraform workspaces are a different feature to Terraform CLI workspaces, and do not compare with Stacks._ | ||
|
||
## Stacks vs. Terragrunt | ||
|
||
[Terragrunt](https://terragrunt.gruntwork.io/) and Stacks achieve very similar results with very different strategies. | ||
|
||
Both enforce a specific directory structure on your repository. | ||
Both generate output code for Terraform to consume. | ||
|
||
Terragrunt adds an [extra layer of configuration](https://terragrunt.gruntwork.io/docs/getting-started/overview/#example) on top of Terraform which lets you define what code it generates. | ||
Terragrunt is heavily influenced by Terraform's [specifics](https://terragrunt.gruntwork.io/docs/features/state-backend/). | ||
It even has special features for [AWS](https://terragrunt.gruntwork.io/docs/features/aws-authentication/). | ||
|
||
Stacks is radically simpler in that it's mainly a thin layer of [Jinja](https://jinja.palletsprojects.com/en/stable/) on top of your Terraform code. | ||
So much so that you can probably use Stacks for other declarative purposes like generating [Kubernetes](https://kubernetes.io/) manifests for [`kubectl`](https://kubernetes.io/docs/reference/kubectl/) to consume, for example. | ||
|
||
_Terragrunt Stacks is a Terragrunt feature that does not compare with Stacks, and while the word "stacks" is overloaded, Stacks existence precedes that of Terragrunt Stacks._ | ||
|
||
## Stacks vs. CDK for Terraform | ||
|
||
Both Stacks and [CDKTF](https://developer.hashicorp.com/terraform/cdktf) can be used to achieve the same results, but again with very different approaches. | ||
|
||
Where Stacks adds a thin layer of Jinja templating on top of the HCL you already know, CDKTF replaces HCL with one of the imperative programming language it supports. | ||
While that can be a good thing if what you want is limitless customizability of your infrastructure set based on imperative logic, we've found that very similar results can be achieved without the complexities CDK for Terraform comes with. | ||
|
||
## Stacks vs. Pulumi | ||
|
||
Everything we said above about CDK for Terraform can be said about Pulumi, as they're basically interchangable. | ||
|
||
## Terraform Cloud Stacks | ||
|
||
Terraform Cloud Stacks is a HCP Terraform feature that enables orchestrating the deployment of multiple interdependent root modules together. | ||
So while the names are the same, HCP Terraform Stacks does not compare with Stacks. | ||
|
||
_And about the word "stacks" being overloaded again: Stacks was initially released on March 2023, Terraform Cloud Stacks was announced later on October that year._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Installation instructions | ||
|
||
## 1. Install Python | ||
|
||
Stacks is written in Python, so it'll need a working [Python](https://www.python.org/downloads/) interpreter on your machine. | ||
|
||
We recommend the version specified in [pyproject.toml](../pyproject.toml). | ||
|
||
## 2. Install `pip` or `uv` | ||
|
||
Stacks is installable with both [`pip`](https://pypi.org/project/pip/) and [`uv`](https://docs.astral.sh/uv/). | ||
|
||
Choose one and install it. If you already have `pip` installed you can skip `uv`, otherwise we recommend the latter. | ||
|
||
## 3. Install Terraform | ||
|
||
Stacks requires [Terraform](https://developer.hashicorp.com/terraform/install) (or [OpenTofu](https://opentofu.org/docs/intro/install/)) to be installed on your machine. | ||
|
||
Stacks will use the binary in the `STACKS_TERRAFORM_PATH` environment variable, which defaults to `terraform` (so it'll look up `terraform` in `$PATH` and use that). | ||
|
||
If you use OpenTofu make sure to set `STACKS_TERRAFORM_PATH` to `tofu`. | ||
|
||
If `STACKS_TERRAFORM_PATH` is not in `$PATH`, you can also set `STACKS_TERRAFORM_PATH` to the absolute path of the binary you want to use (e.g.: `STACKS_TERRAFORM_PATH=/usr/bin/terraform`). | ||
|
||
## 4. Install Stacks | ||
|
||
To install Stacks using `pip`: | ||
```shell | ||
pip3 install --break-system-packages git+https://github.com/cisco-open/stacks.git | ||
``` | ||
|
||
To install Stacks using `uv`: | ||
```shell | ||
uv tool install git+https://github.com/cisco-open/stacks.git | ||
``` | ||
|
||
For development, we recommend you install Stacks from source: | ||
```shell | ||
git clone [email protected]:cisco-open/stacks.git | ||
cd stacks/ | ||
uv tool install --editable . | ||
``` | ||
The `--editable` flag allows you to try your changes right away without reinstalling `stacks`. |
Oops, something went wrong.