-
Notifications
You must be signed in to change notification settings - Fork 0
/
stacks.tf
39 lines (34 loc) · 1.51 KB
/
stacks.tf
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
locals {
stack_dependencies = {
for stack in var.stacks : stack.name => flatten([
for dependency in stack.dependencies : [
"dep:${var.global_project_root != "" ? "${var.global_project_root}/" : ""}${dependency}"
]
]) if stack.dependencies != null
}
}
resource "spacelift_stack" "main" {
for_each = { for stack in var.stacks : stack.name => stack }
administrative = false
autodeploy = true
branch = var.trunk_branch
description = "${each.value.description != null && each.value.description != "" ? "${each.value.description} - " : ""}Managed by Terraform"
enable_local_preview = false
labels = flatten([lookup(local.stack_dependencies, each.value.name, []), each.value.additional_labels != null ? each.value.additional_labels : []])
manage_state = false
name = each.value.name
project_root = "${var.global_project_root != null && var.global_project_root != "" ? "${var.global_project_root}/" : ""}${each.value.project_root}"
protect_from_deletion = var.global_stack_delete_protection
repository = var.git_repository
terraform_version = var.terraform_version
}
resource "spacelift_aws_integration_attachment" "main" {
for_each = { for stack in var.stacks : stack.name => stack }
integration_id = var.aws_integration_id
stack_id = spacelift_stack.main[each.value.name].id
read = true
write = true
depends_on = [
spacelift_stack.main
]
}