You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardexpand all lines: README.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,9 @@ This Terraform child module provides infrastructure automation for projects in [
6
6
7
7
## Overview
8
8
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)
10
12
11
13
It automates the creation of "child" stacks and all the required accompanying Spacelift resources. For each enabled root module it creates:
12
14
@@ -37,7 +39,7 @@ Structure requirements:
37
39
- 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`.
38
40
- 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.
39
41
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:
41
43
42
44
```sh
43
45
├── root-modules
@@ -179,7 +181,7 @@ Spacelift Automation can manage itself as a Stack as well, and we recommend this
179
181
4. Move the Automation configs to the `<root-modules>/spacelift-automation/stacks` directory and push the changes to the tracked repo and branch.
180
182
5. After pushed to your repo's tracked branch, Spacelift Automation will track the addition of new root modules and create Stacks for them.
181
183
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).
183
185
184
186
<!-- NOTE to Masterpoint team: We might want to create a small wrapper to automatize this using Taskit. On hold for now. -->
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.
4
4
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/).
6
6
7
7
By doing this, we provide an example of how to set up Spacelift to automate the management of your infrastructure stacks, including itself.
8
8
@@ -11,28 +11,35 @@ By doing this, we provide an example of how to set up Spacelift to automate the
11
11
1. Prerequisites:
12
12
- Replace the following configuration files with your own values:
13
13
-`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
16
16
> **Important:** These files may contain sensitive information. Ensure you:
17
17
>
18
18
> - Remove any hardcoded credentials or sensitive values
19
19
> - Have appropriate Spacelift ([`SPACELIFT_API_KEY_*`](https://docs.spacelift.io/concepts/spacectl#spacelift-api-keys) environment variables) and AWS permissions
20
20
> - 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
+
22
23
```sh
23
-
cd ./components/spacelift-automation/
24
+
cd ./root-modules/spacelift-automation/
24
25
```
26
+
25
27
3. Initialize Terraform:
28
+
26
29
```sh
27
30
tofu init
28
31
```
29
-
4. Select the worspace:
32
+
33
+
4. Review the Terraform plan:
34
+
30
35
```sh
31
-
tofu workspace selectexample
36
+
tofu plan
32
37
```
33
-
5. Review the Terraform plan:
38
+
39
+
5. Apply the Terraform plan:
40
+
34
41
```sh
35
-
tofu plan -var-file tfvars/example.tfvars
42
+
tofu apply
36
43
```
37
44
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.
0 commit comments