From 735c38131be60ff7731f7bd4ec51492d97eb1909 Mon Sep 17 00:00:00 2001 From: Steven Nemetz Date: Tue, 10 Jul 2018 09:48:31 -0700 Subject: [PATCH] Add option to disable modules --- TODO.txt | 3 +++ modules/pagerduty/main.tf | 8 +++++++- modules/pagerduty/variables.tf | 5 +++++ modules/slack/main.tf | 8 +++++++- modules/slack/variables.tf | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 TODO.txt diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..fc402ef --- /dev/null +++ b/TODO.txt @@ -0,0 +1,3 @@ + +Combine lambdas into 1 +- determine which integration to setup by parsing event data diff --git a/modules/pagerduty/main.tf b/modules/pagerduty/main.tf index cf14883..22a7718 100644 --- a/modules/pagerduty/main.tf +++ b/modules/pagerduty/main.tf @@ -1,5 +1,11 @@ +module "enabled" { + source = "devops-workflow/boolean/local" + version = "0.1.2" + value = "${var.enabled}" +} + locals { - enabled = "${length(var.service_key) > 0 ? 1 : 0}" + enabled = "${module.enabled.value && length(var.service_key) > 0 ? 1 : 0}" } data "template_file" "pagerduty_service" { diff --git a/modules/pagerduty/variables.tf b/modules/pagerduty/variables.tf index 7288252..508bffe 100644 --- a/modules/pagerduty/variables.tf +++ b/modules/pagerduty/variables.tf @@ -3,6 +3,11 @@ variable "datadog_default" { default = "" } +variable "enabled" { + description = "Set to false to prevent the module from creating anything" + default = true +} + variable "service_key" { description = "PagerDuty service integration key" default = "" diff --git a/modules/slack/main.tf b/modules/slack/main.tf index 010e486..fe3f1df 100644 --- a/modules/slack/main.tf +++ b/modules/slack/main.tf @@ -3,8 +3,14 @@ # Channel name is empty # Channel name has format mon-- but nothing after second - +module "enabled" { + source = "devops-workflow/boolean/local" + version = "0.1.2" + value = "${var.enabled}" +} + locals { - enabled = "${length(replace(var.channel_name, "/(mon-\\w+-)(.*)$/", "$2")) > 0 ? 1 : 0}" + enabled = "${module.enabled.value && length(replace(var.channel_name, "/(mon-\\w+-)(.*)$/", "$2")) > 0 ? 1 : 0}" } data "template_file" "slack_channel" { diff --git a/modules/slack/variables.tf b/modules/slack/variables.tf index 6310584..4eb936c 100644 --- a/modules/slack/variables.tf +++ b/modules/slack/variables.tf @@ -3,6 +3,11 @@ variable "channel_name" { default = "" } +variable "enabled" { + description = "Set to false to prevent the module from creating anything" + default = true +} + variable "s3_base" { description = "Base path in S3 bucket for Slack configuration pieces" default = "datadog/integration/slack"