Skip to content

Commit

Permalink
Add pre/post scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
caruccio committed Jul 7, 2022
1 parent ea11263 commit 0d056c6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION:=2.21
VERSION:=2.22

test: fmt init validate

Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ module "flux" {
module.teleport-agent.teleport_agent_config,
var.manifests_template_vars
)

depends_on = [
shell_script.pre_create
]
}

module "cronitor" {
Expand Down
29 changes: 29 additions & 0 deletions scripts.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "shell_script" "pre_create" {
for_each = toset(var.pre_create)

lifecycle_commands {
create = each.value
read = "echo {}"
update = each.value
delete = "echo {}"
}

environment = {}
}

resource "shell_script" "post_create" {
for_each = toset(var.post_create)

lifecycle_commands {
create = each.value
read = "echo {}"
update = each.value
delete = "echo {}"
}

environment = {}

depends_on = [
module.flux
]
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,15 @@ variable "use_kubeconfig" {
type = bool
default = false
}

variable "pre_create" {
description = "Scripts to execute before cluster is created."
type = list(string)
default = []
}

variable "post_create" {
description = "Scripts to execute after cluster is created."
type = list(string)
default = []
}

0 comments on commit 0d056c6

Please sign in to comment.