Skip to content

Commit 735c381

Browse files
author
Steven Nemetz
committed
Add option to disable modules
1 parent d781284 commit 735c381

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

TODO.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
Combine lambdas into 1
3+
- determine which integration to setup by parsing event data

modules/pagerduty/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
module "enabled" {
2+
source = "devops-workflow/boolean/local"
3+
version = "0.1.2"
4+
value = "${var.enabled}"
5+
}
6+
17
locals {
2-
enabled = "${length(var.service_key) > 0 ? 1 : 0}"
8+
enabled = "${module.enabled.value && length(var.service_key) > 0 ? 1 : 0}"
39
}
410

511
data "template_file" "pagerduty_service" {

modules/pagerduty/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ variable "datadog_default" {
33
default = ""
44
}
55

6+
variable "enabled" {
7+
description = "Set to false to prevent the module from creating anything"
8+
default = true
9+
}
10+
611
variable "service_key" {
712
description = "PagerDuty service integration key"
813
default = ""

modules/slack/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
# Channel name is empty
44
# Channel name has format mon-<env>-<service short name> but nothing after second -
55

6+
module "enabled" {
7+
source = "devops-workflow/boolean/local"
8+
version = "0.1.2"
9+
value = "${var.enabled}"
10+
}
11+
612
locals {
7-
enabled = "${length(replace(var.channel_name, "/(mon-\\w+-)(.*)$/", "$2")) > 0 ? 1 : 0}"
13+
enabled = "${module.enabled.value && length(replace(var.channel_name, "/(mon-\\w+-)(.*)$/", "$2")) > 0 ? 1 : 0}"
814
}
915

1016
data "template_file" "slack_channel" {

modules/slack/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ variable "channel_name" {
33
default = ""
44
}
55

6+
variable "enabled" {
7+
description = "Set to false to prevent the module from creating anything"
8+
default = true
9+
}
10+
611
variable "s3_base" {
712
description = "Base path in S3 bucket for Slack configuration pieces"
813
default = "datadog/integration/slack"

0 commit comments

Comments
 (0)