Skip to content

Commit 28c4217

Browse files
authored
docs: improve examples/complete + overall docs (#41)
* chore: updates examples w/ more full use-case * chore: updates complete example to use policies module * chore: adds video intro for spacelift-automation * fix: add `some j` for looping tracked extensions
1 parent e0667ac commit 28c4217

File tree

34 files changed

+604
-102
lines changed

34 files changed

+604
-102
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ This Terraform child module provides infrastructure automation for projects in [
66

77
## Overview
88

9-
The `spacelift-automation` root module is designed to streamline the deployment and management of all Spacelift infrastructure, including creating a Spacelift Stack to manage itself.
9+
This `spacelift-automation` child module is designed to streamline the deployment and management of all Spacelift infrastructure, including creating a Spacelift Stack to manage itself.
10+
11+
Check out our quick introduction to this child module here: [![[External] terraform-spacelift-automation quick intro - Watch Video](https://cdn.loom.com/sessions/thumbnails/8de21afb732048a58fdee90042b4840f-11908d1d42de3247-full-play.gif)](https://www.loom.com/share/8de21afb732048a58fdee90042b4840f)
1012

1113
It automates the creation of "child" stacks and all the required accompanying Spacelift resources. For each enabled root module it creates:
1214

@@ -37,7 +39,7 @@ Structure requirements:
3739
- Stack config files and tfvars files must be equal to OpenTofu/Terraform workspace, e.g. `stacks/dev.yaml` and `tfvars/dev.tfvars` for a workspace named `dev`.
3840
- Common configs are placed in `<root_modules_path>/<root_module>/stacks/common.yaml` file (or `var.common_config_file` value). This is useful when you know that some values should be shared across all the stacks created for a root module. For example, all stacks that manage Spacelift Policies must use the `administrative: true` setting or all stacks must share the same labels.
3941

40-
We have an example of this structure in the [examples/complete](./examples/complete/components/), which looks like the following:
42+
We have an example of this structure in the [examples/complete](./examples/complete/root-modules/), which looks like the following:
4143

4244
```sh
4345
├── root-modules
@@ -179,7 +181,7 @@ Spacelift Automation can manage itself as a Stack as well, and we recommend this
179181
4. Move the Automation configs to the `<root-modules>/spacelift-automation/stacks` directory and push the changes to the tracked repo and branch.
180182
5. After pushed to your repo's tracked branch, Spacelift Automation will track the addition of new root modules and create Stacks for them.
181183

182-
Check out an example configuration in the [examples/complete](./examples/complete/components/spacelift-automation/tfvars/example.tfvars).
184+
Check out an example configuration in the [examples/complete](./examples/complete/root-modules/spacelift-automation/tfvars/example.tfvars).
183185

184186
<!-- NOTE to Masterpoint team: We might want to create a small wrapper to automatize this using Taskit. On hold for now. -->
185187

examples/complete/README.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Complete Example
22

3-
This example demonstrates how to use the spacelift-automation component to manage Spacelift stacks, including the ability for Spacelift to manage its own configuration.
3+
This example demonstrates how to use the spacelift-automation child-module as a root-module to manage Spacelift stacks, including the ability for Spacelift to manage its own configuration.
44

5-
Normally, this directory would contain a simple root module to spin up a basic example. To showcase a more practical use case where Spacelift manages its own infrastructure, we’ve moved the configuration to the expected path: [examples/complete/components/spacelift-automation/](./components/spacelift-automation/).
5+
Normally, this directory would contain a simple root module to spin up a basic example. To showcase a more practical use case where Spacelift manages its own infrastructure, we’ve moved the configuration to the expected path: [examples/complete/root-modules/spacelift-automation/](./root-modules/spacelift-automation/).
66

77
By doing this, we provide an example of how to set up Spacelift to automate the management of your infrastructure stacks, including itself.
88

@@ -11,28 +11,35 @@ By doing this, we provide an example of how to set up Spacelift to automate the
1111
1. Prerequisites:
1212
- Replace the following configuration files with your own values:
1313
- `backend.tf.json`: Configure your Terraform backend settings
14-
- `example.tfvars`: Set your Spacelift configuration variables
15-
- `example.yaml`: Define your stack configuration
14+
- `main.tf`: Because this root module only has one instance, we manage the variables passed to it via the `main.tf` file. You'll want to change those values to match your own.
15+
- `stacks/common.yaml`: Define your stack configuration
1616
> **Important:** These files may contain sensitive information. Ensure you:
1717
>
1818
> - Remove any hardcoded credentials or sensitive values
1919
> - Have appropriate Spacelift ([`SPACELIFT_API_KEY_*`](https://docs.spacelift.io/concepts/spacectl#spacelift-api-keys) environment variables) and AWS permissions
2020
> - Follow your organization's security practices
21-
2. Navigate to the spacelift-automation component directory:
21+
2. Navigate to the spacelift-automation root-modules directory:
22+
2223
```sh
23-
cd ./components/spacelift-automation/
24+
cd ./root-modules/spacelift-automation/
2425
```
26+
2527
3. Initialize Terraform:
28+
2629
```sh
2730
tofu init
2831
```
29-
4. Select the worspace:
32+
33+
4. Review the Terraform plan:
34+
3035
```sh
31-
tofu workspace select example
36+
tofu plan
3237
```
33-
5. Review the Terraform plan:
38+
39+
5. Apply the Terraform plan:
40+
3441
```sh
35-
tofu plan -var-file tfvars/example.tfvars
42+
tofu apply
3643
```
3744

38-
This will set up the Spacelift stack that manages itself.
45+
This will set up the Spacelift Stack that manages itself and the rest of the Stacks in the root-modules directory as well.

examples/complete/components/random-pet/stacks/common.yaml

-5
This file was deleted.

examples/complete/components/random-pet/stacks/dev.yaml

-5
This file was deleted.

examples/complete/components/random-pet/tfvars/dev.tfvars

-1
This file was deleted.

examples/complete/components/random-pet/variables.tf

-4
This file was deleted.

examples/complete/components/spacelift-automation/main.tf

-15
This file was deleted.

examples/complete/components/spacelift-automation/stacks/example.yaml

-5
This file was deleted.

examples/complete/components/spacelift-automation/tfvars/example.tfvars

-8
This file was deleted.

examples/complete/components/spacelift-automation/variables.tf

-41
This file was deleted.

0 commit comments

Comments
 (0)