Skip to content

Commit

Permalink
Add option to disable modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Nemetz committed Jul 10, 2018
1 parent d781284 commit 735c381
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

Combine lambdas into 1
- determine which integration to setup by parsing event data
8 changes: 7 additions & 1 deletion modules/pagerduty/main.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand Down
5 changes: 5 additions & 0 deletions modules/pagerduty/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
8 changes: 7 additions & 1 deletion modules/slack/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# Channel name is empty
# Channel name has format mon-<env>-<service short name> 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" {
Expand Down
5 changes: 5 additions & 0 deletions modules/slack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 735c381

Please sign in to comment.