Skip to content

Commit

Permalink
Merge branch 'main' into trunk-io/update-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
gberenice authored Nov 11, 2024
2 parents 98987af + d790607 commit 58f2a39
Show file tree
Hide file tree
Showing 24 changed files with 906 additions and 307 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

# Output from other tools that might be used alongside Terraform/OpenTofu
*.tfvars.json
backend.tf.json

# Taskit files
.taskit/
Expand All @@ -39,4 +38,4 @@ backend.tf.json
**/*.temp
**/*.bak
**/*.*swp
**/.DS_Store
**/.DS_Store
182 changes: 173 additions & 9 deletions README.md

Large diffs are not rendered by default.

279 changes: 0 additions & 279 deletions context.tf

This file was deleted.

38 changes: 38 additions & 0 deletions examples/complete/README.md
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.
3 changes: 3 additions & 0 deletions examples/complete/components/random-pet/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "random_pet" "template" {
length = var.length
}
3 changes: 3 additions & 0 deletions examples/complete/components/random-pet/stacks/common.yaml
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
2 changes: 2 additions & 0 deletions examples/complete/components/random-pet/stacks/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stack_settings:
manage_state: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
length = 10
4 changes: 4 additions & 0 deletions examples/complete/components/random-pet/variables.tf
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
}
10 changes: 10 additions & 0 deletions examples/complete/components/random-pet/versions.tf
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 examples/complete/components/spacelift-automation/backend.tf.json
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"
}
}
}
}
}
12 changes: 12 additions & 0 deletions examples/complete/components/spacelift-automation/main.tf
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stack_settings:
administrative: true
aws_integration_enabled: true
Loading

0 comments on commit 58f2a39

Please sign in to comment.