From e4d1f7071b7ab34222f022888c969883abacb635 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Mon, 17 Jun 2019 12:23:50 -0400 Subject: [PATCH 1/6] Make New Relic alerts optional --- terraform/newrelic.tf | 4 ++-- terraform/variables.tf | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/terraform/newrelic.tf b/terraform/newrelic.tf index 518e193..670d193 100644 --- a/terraform/newrelic.tf +++ b/terraform/newrelic.tf @@ -32,7 +32,7 @@ resource "newrelic_alert_condition" "spin-appdex" { condition_scope = "application" - count = "${length(var.newrelic_apm_entities) > 0 ? 1 : 0}" + count = "${length(var.newrelic_apm_entities) > 0 ? (var.newrelic_alerts ? 1 : 0) : 0}" } # Add a notification channel @@ -45,7 +45,7 @@ resource "newrelic_alert_channel" "email" { include_json_attachment = "1" } - count = "${length(var.newrelic_alert_email) > 0 ? 1 : 0}" + count = "${length(var.newrelic_alert_email) > 0 ? (var.newrelic_alerts ? 1 : 0) : 0}" } # Link the channel to the policy diff --git a/terraform/variables.tf b/terraform/variables.tf index ba95f70..0ac2282 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -96,6 +96,12 @@ variable "newrelic_apm_entities" { default = [] } +# You have to have a full-blown New Relic subscription in order to deal with Alerts +variable "newrelic_alerts" { + description = "Enable New Relic alerts" + default = false +} + variable "newrelic_runbook_url" { description = "New Relic runbook URL" default = "https://github.com/ModusCreateOrg/devops-infra-demo/wiki/runbook" From 8000160893e708f0e2f950135e97d49719e1cdec Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Mon, 17 Jun 2019 14:28:40 -0400 Subject: [PATCH 2/6] Pin module version of vpc per docs See https://github.com/terraform-aws-modules/terraform-aws-vpc : Terraform 0.12. Pin module version to `~> v2.0`. Submit pull-requests to `master` branch. Terraform 0.11. Pin module version to `~> v1.0`. Submit pull-requests to `terraform011` branch. --- terraform/vpc.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/vpc.tf b/terraform/vpc.tf index 1436b27..5acdd5d 100644 --- a/terraform/vpc.tf +++ b/terraform/vpc.tf @@ -1,5 +1,6 @@ module "vpc" { - source = "github.com/terraform-aws-modules/terraform-aws-vpc" + source = "terraform-aws-modules/vpc/aws" + version = "~> v1.0" name = "infra-demo-vpc" From f981cc5dd8868411db84bc37c690ff4c03f19624 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Mon, 17 Jun 2019 16:00:36 -0400 Subject: [PATCH 3/6] Apply terraform fmt --- terraform/vpc.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/vpc.tf b/terraform/vpc.tf index 5acdd5d..63063b7 100644 --- a/terraform/vpc.tf +++ b/terraform/vpc.tf @@ -1,5 +1,5 @@ module "vpc" { - source = "terraform-aws-modules/vpc/aws" + source = "terraform-aws-modules/vpc/aws" version = "~> v1.0" name = "infra-demo-vpc" From f551ff443b9b15f1bb990ea9fe09a2542799f7c6 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Mon, 17 Jun 2019 16:02:37 -0400 Subject: [PATCH 4/6] Clean up better --- bin/clean-workspace.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/clean-workspace.sh b/bin/clean-workspace.sh index a227196..09e99c9 100755 --- a/bin/clean-workspace.sh +++ b/bin/clean-workspace.sh @@ -22,4 +22,5 @@ export BASE_DIR cp "$BASE_DIR/env.sh.sample" "$BASE_DIR/env.sh" clean_root_owned_docker_files rm -rf "$BUILD_DIR" +git clean -fdx mkdir "$BUILD_DIR" From ae2a0c626dc71fd352da7a9278f145b9f1072b7d Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Mon, 17 Jun 2019 16:03:54 -0400 Subject: [PATCH 5/6] Clean more things - including .terraform dir --- bin/clean-workspace.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/clean-workspace.sh b/bin/clean-workspace.sh index 09e99c9..8e9eb0d 100755 --- a/bin/clean-workspace.sh +++ b/bin/clean-workspace.sh @@ -21,6 +21,5 @@ export BASE_DIR cp "$BASE_DIR/env.sh.sample" "$BASE_DIR/env.sh" clean_root_owned_docker_files -rm -rf "$BUILD_DIR" -git clean -fdx +rm -rf "$BUILD_DIR" "$BASE_DIR/terraform/.terraform" mkdir "$BUILD_DIR" From f947f22c29f97e0fc466212c57609af12da5c5fe Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 18 Jun 2019 17:41:20 -0400 Subject: [PATCH 6/6] Try to squish New Relic alerts unless configured --- terraform/newrelic.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/newrelic.tf b/terraform/newrelic.tf index 670d193..228a77f 100644 --- a/terraform/newrelic.tf +++ b/terraform/newrelic.tf @@ -53,7 +53,7 @@ resource "newrelic_alert_policy_channel" "alert_email" { policy_id = "${newrelic_alert_policy.alert.id}" channel_id = "${newrelic_alert_channel.email.id}" - count = "${length(var.newrelic_alert_email) > 0 ? 1 : 0}" + count = "${length(var.newrelic_alert_email) > 0 ? (var.newrelic_alerts ? 1 : 0) : 0}" } # Add a dashboard