generated from masterpointio/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into trunk-io/update-trunk
- Loading branch information
Showing
24 changed files
with
906 additions
and
307 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
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
# Complete Example | ||
|
||
This example demonstrates how to use the spacelift-automation component to manage Spacelift stacks, including the ability for Spacelift to manage its own configuration. | ||
|
||
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/). | ||
|
||
By doing this, we provide an example of how to set up Spacelift to automate the management of your infrastructure stacks, including itself. | ||
|
||
## Use the Example | ||
|
||
1. Prerequisites: | ||
- Replace the following configuration files with your own values: | ||
- `backend.tf.json`: Configure your Terraform backend settings | ||
- `example.tfvars`: Set your Spacelift configuration variables | ||
- `example.yaml`: Define your stack configuration | ||
> **Important:** These files may contain sensitive information. Ensure you: | ||
> | ||
> - Remove any hardcoded credentials or sensitive values | ||
> - Have appropriate Spacelift and AWS permissions | ||
> - Follow your organization's security practices | ||
1. Navigate to the spacelift-automation component directory: | ||
```sh | ||
cd ./components/spacelift-automation/ | ||
``` | ||
1. Initialize Terraform: | ||
```sh | ||
tofu init | ||
``` | ||
1. Select the worspace: | ||
```sh | ||
tofu workspace select example | ||
``` | ||
1. Review the Terraform plan: | ||
```sh | ||
tofu plan -var-file tfvars/example.tfvars | ||
``` | ||
This will set up the Spacelift stack that manages itself. |
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,3 @@ | ||
resource "random_pet" "template" { | ||
length = var.length | ||
} |
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,3 @@ | ||
stack_settings: | ||
manage_state: true | ||
description: This stack generates random pet names |
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,2 @@ | ||
stack_settings: | ||
manage_state: true |
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 @@ | ||
length = 10 |
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,4 @@ | ||
variable "length" { | ||
description = "The length of the random name" | ||
type = number | ||
} |
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,10 @@ | ||
terraform { | ||
required_version = "~> 1.0" | ||
|
||
required_providers { | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/complete/components/spacelift-automation/backend.tf.json
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,18 @@ | ||
{ | ||
"terraform": { | ||
"backend": { | ||
"s3": { | ||
"workspace_key_prefix": "terraform-spacelift-automation", | ||
"acl": "bucket-owner-full-control", | ||
"bucket": "mp-automation-tfstate", | ||
"dynamodb_table": "mp-automation-tfstate-lock", | ||
"encrypt": true, | ||
"key": "terraform.tfstate", | ||
"region": "us-east-1", | ||
"assume_role": { | ||
"role_arn": "arn:aws:iam::755965222190:role/mp-automation-tfstate" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,12 @@ | ||
module "automation" { | ||
source = "../../../../" | ||
|
||
github_enterprise = var.github_enterprise | ||
repository = var.repository | ||
branch = var.branch | ||
|
||
root_modules_path = var.root_modules_path | ||
all_root_modules_enabled = var.all_root_modules_enabled | ||
|
||
aws_integration_id = var.aws_integration_id | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/complete/components/spacelift-automation/stacks/common.yaml
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,3 @@ | ||
stack_settings: | ||
administrative: true | ||
aws_integration_enabled: true |
Oops, something went wrong.