File tree Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -88,18 +88,21 @@ module jenkins {
8888| ------| ---------|
8989| terraform | >= 0.13 |
9090| helm | >= 2.0 |
91+ | null | >= 3.0 |
9192
9293## Providers
9394
9495| Name | Version |
9596| ------| ---------|
9697| helm | >= 2.0 |
98+ | null | >= 3.0 |
9799
98100## Inputs
99101
100102| Name | Description | Type | Default | Required |
101103| ------| -------------| ------| ---------| :--------:|
102104| app | an application to deploy | ` map(any) ` | n/a | yes |
105+ | manage\_ repo | Whether Helm repo should be added, updated and removed during Terraform execution | ` bool ` | ` false ` | no |
103106| namespace | namespace where to deploy an application | ` string ` | n/a | yes |
104107| repository | Helm repository | ` string ` | n/a | yes |
105108| repository\_ config | repository configuration | ` map(any) ` | n/a | yes |
Original file line number Diff line number Diff line change 1+ resource "null_resource" "repo_add" {
2+ count = var. manage_repo ? 1 : 0
3+
4+ triggers = {
5+ always_run = " ${ timestamp ()} "
6+ }
7+
8+ provisioner "local-exec" {
9+ command = " helm repo add ${ var . app [" chart" ]} ${ var . repository } "
10+ }
11+ }
12+
13+ resource "null_resource" "repo_update" {
14+ count = var. manage_repo ? 1 : 0
15+
16+ triggers = {
17+ always_run = " ${ timestamp ()} "
18+ }
19+
20+ provisioner "local-exec" {
21+ command = " helm repo update ${ var . app [" chart" ]} "
22+ }
23+
24+ depends_on = [
25+ resource . null_resource . repo_add [0 ]
26+ ]
27+ }
28+
129resource "helm_release" "this" {
230 count = var. app [" deploy" ] ? 1 : 0
331 namespace = var. namespace
@@ -49,4 +77,25 @@ resource "helm_release" "this" {
4977 value = item. value . value
5078 }
5179 }
80+
81+ depends_on = [
82+ resource . null_resource . repo_update
83+ ]
84+ }
85+
86+ resource "null_resource" "repo_delete" {
87+ count = var. manage_repo ? 1 : 0
88+
89+ triggers = {
90+ always_run = " ${ timestamp ()} "
91+ }
92+
93+ provisioner "local-exec" {
94+ command = " helm repo remove ${ var . app [" chart" ]} "
95+ }
96+
97+ depends_on = [
98+ resource . null_resource . repo_add [0 ],
99+ resource . helm_release . this
100+ ]
52101}
Original file line number Diff line number Diff line change @@ -42,3 +42,9 @@ variable "repository" {
4242 description = " Helm repository"
4343 type = string
4444}
45+
46+ variable "manage_repo" {
47+ description = " Whether Helm repo should be added, updated and removed during Terraform execution"
48+ default = false
49+ type = bool
50+ }
Original file line number Diff line number Diff line change @@ -3,5 +3,6 @@ terraform {
33
44 required_providers {
55 helm = " >= 2.0"
6+ null = " >= 3.0"
67 }
78}
You can’t perform that action at this time.
0 commit comments