-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.tf
More file actions
42 lines (34 loc) · 1.27 KB
/
main.tf
File metadata and controls
42 lines (34 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Create a stack for each path after filtering out ignore_paths
resource "spacelift_stack" "dynamic_stacks" {
for_each = local.stacks_clean_folders_filtered
name = each.key
administrative = contains(local.administrative_paths, each.key)
autodeploy = true
project_root = each.key
repository = "dynamic-spacelift-stacks-example"
branch = "main"
terraform_version = "1.2.3"
labels = [
"dynamic"
]
github_enterprise {
namespace = "spacelift-io-examples"
}
}
# Triggers the stack after creation
resource "spacelift_run" "this" {
for_each = local.stacks_clean_folders_filtered
stack_id = spacelift_stack.dynamic_stacks[each.key].id
}
# Create the ignore changes outside root policy from file
resource "spacelift_policy" "ignore_changes_outside_root_policy" {
name = "Ignore changes outside root."
body = file("${path.module}/policies/ignore-changes-outside-root.rego")
type = "GIT_PUSH"
}
# Attach the ignore changes outside root policy to each stack
resource "spacelift_policy_attachment" "ignore_changes_outside_root_attachment" {
for_each = local.stacks_clean_folders_filtered
policy_id = spacelift_policy.ignore_changes_outside_root_policy.id
stack_id = spacelift_stack.dynamic_stacks[each.key].id
}