From 74b8f7398ac2f7a36e828b0f1cd693d2ed1cbbc6 Mon Sep 17 00:00:00 2001 From: "edson.siqueira@dnx.solutions" Date: Fri, 17 Jun 2022 13:04:04 -0300 Subject: [PATCH 1/5] Changing variables and adding examples after some tests with this module --- Cloudwatch-metric-alarm.tf | 3 ++- _variables.tf | 23 +++++++++++++++++------ examples/one.yaml | 21 +++++++++++++++++++++ examples/route53_health_check.tf | 13 +++++++++++++ route53-healthcheck.tf | 4 ++-- 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 examples/one.yaml create mode 100644 examples/route53_health_check.tf diff --git a/Cloudwatch-metric-alarm.tf b/Cloudwatch-metric-alarm.tf index 7e7f006..94b5005 100644 --- a/Cloudwatch-metric-alarm.tf +++ b/Cloudwatch-metric-alarm.tf @@ -1,5 +1,6 @@ resource "aws_cloudwatch_metric_alarm" "health_check" { - alarm_name = "route53-healthcheck/${var.name}" + count = try(var.cloudwatch_alarms_enabled, false) ? 1 : 0 + alarm_name = "route53-healthcheck/${var.hostname}" metric_name = "HealthCheckStatus" comparison_operator = "LessThanThreshold" evaluation_periods = "2" diff --git a/_variables.tf b/_variables.tf index 6b32214..1e39bc1 100644 --- a/_variables.tf +++ b/_variables.tf @@ -1,6 +1,6 @@ -variable "name" { - description = "Name of app service needs to be checked" -} +# variable "name" { +# description = "Name of app service needs to be checked" +# } variable "port" { default = "80" @@ -24,17 +24,28 @@ variable "protocol" { } variable "threshold" { - default = 1 + default = 2 } variable "period" { default = 60 } -variable "time_request" { +variable "request_interval" { default = 30 } variable "failure_threshold" { - default = 2 + default = 3 } + +variable "measure_latency" { + type = bool + default = false + description = "Latency between health checkers in multiple AWS regions and your endpoint and to display CloudWatch latency graphs in the Route 53 console" +} + +variable "cloudwatch_alarms_enabled" { + type = bool + default = false +} \ No newline at end of file diff --git a/examples/one.yaml b/examples/one.yaml new file mode 100644 index 0000000..535e91b --- /dev/null +++ b/examples/one.yaml @@ -0,0 +1,21 @@ +workspaces: + prod-ap-southeast-2: + route53_health_check: + health_check_enable: true + endpoints: + - hostname: www.example.com + port: 8443 + protocol: HTTPS + healthcheck_path: /healthcheck + measure_latency: true + - hostname: www.myportal.com + port: 443 + protocol: HTTPS + healthcheck_path: + measure_latency: true + + aws_cloudwatch_metric_alarm: [] + # cloudwatch_alarms_enabled: true + # - alarm_name: + # period: + # aws_sns_topic_arn: \ No newline at end of file diff --git a/examples/route53_health_check.tf b/examples/route53_health_check.tf new file mode 100644 index 0000000..65c7aea --- /dev/null +++ b/examples/route53_health_check.tf @@ -0,0 +1,13 @@ +module "terraform-aws-route53healthcheck" { + source = "git::https://github.com/DNXLabs/terraform-aws-route53healthcheck.git?ref=0.1.1" + for_each = { for healthcheck in try(local.workspace.route53_health_check.endpoint, []) : healthcheck.hostname => healthcheck } + providers = { + aws = aws.us-east-1 + } + + hostname = try(each.value.hostname, "[]") + port = try(each.value.port, 443 ) + protocol = try(each.value.protocol, "HTTPS" ) + healthcheck_path = try(each.value.healthcheck_path, "") + measure_latency = try(each.value.measure_latency, true) +} \ No newline at end of file diff --git a/route53-healthcheck.tf b/route53-healthcheck.tf index 9ab126b..8cdab59 100644 --- a/route53-healthcheck.tf +++ b/route53-healthcheck.tf @@ -1,5 +1,5 @@ resource "aws_route53_health_check" "default" { - reference_name = var.name + # reference_name = var.name fqdn = var.hostname port = var.port type = var.protocol @@ -9,6 +9,6 @@ resource "aws_route53_health_check" "default" { #insufficient_data_health_status = "Healthy" tags = { - Name = var.name + Name = var.hostname } } From 8b9522502b2dec456a471c320aa80d14014ea889 Mon Sep 17 00:00:00 2001 From: soareseds Date: Fri, 17 Jun 2022 16:07:05 +0000 Subject: [PATCH 2/5] terraform-docs: automated update action --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e673935..8d6f661 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,16 @@ In addition you have the option to: | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | aws\_sns\_topic\_arn | n/a | `string` | `""` | no | -| failure\_threshold | n/a | `number` | `2` | no | +| cloudwatch\_alarms\_enabled | n/a | `bool` | `false` | no | +| failure\_threshold | n/a | `number` | `3` | no | | healthcheck\_path | n/a | `string` | `"/"` | no | | hostname | app Hostname to check | `any` | n/a | yes | -| name | Name of app service needs to be checked | `any` | n/a | yes | +| measure\_latency | Latency between health checkers in multiple AWS regions and your endpoint and to display CloudWatch latency graphs in the Route 53 console | `bool` | `false` | no | | period | n/a | `number` | `60` | no | | port | Port for target check | `string` | `"80"` | no | | protocol | n/a | `string` | `"HTTP"` | no | -| threshold | n/a | `number` | `1` | no | -| time\_request | n/a | `number` | `30` | no | +| request\_interval | n/a | `number` | `30` | no | +| threshold | n/a | `number` | `2` | no | ## Outputs From 38777d65d539efffeb7a4a2ccd3fb71b207bf477 Mon Sep 17 00:00:00 2001 From: "edson.siqueira@dnx.solutions" Date: Fri, 17 Jun 2022 13:27:53 -0300 Subject: [PATCH 3/5] Fixing fmt and missing variable --- _variables.tf | 4 ++-- route53-healthcheck.tf | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/_variables.tf b/_variables.tf index 1e39bc1..9d03709 100644 --- a/_variables.tf +++ b/_variables.tf @@ -46,6 +46,6 @@ variable "measure_latency" { } variable "cloudwatch_alarms_enabled" { - type = bool - default = false + type = bool + default = false } \ No newline at end of file diff --git a/route53-healthcheck.tf b/route53-healthcheck.tf index 8cdab59..070d459 100644 --- a/route53-healthcheck.tf +++ b/route53-healthcheck.tf @@ -5,10 +5,11 @@ resource "aws_route53_health_check" "default" { type = var.protocol resource_path = var.healthcheck_path failure_threshold = var.failure_threshold - request_interval = var.time_request + request_interval = var.request_interval + measure_latency = var.measure_latency #insufficient_data_health_status = "Healthy" tags = { Name = var.hostname } -} +} \ No newline at end of file From d4a0d5ac8e347e827114b594b9ae6088304457a2 Mon Sep 17 00:00:00 2001 From: "edson.siqueira@dnx.solutions" Date: Fri, 17 Jun 2022 14:36:13 -0300 Subject: [PATCH 4/5] Fixing fmt and missing variable --- route53-healthcheck.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/route53-healthcheck.tf b/route53-healthcheck.tf index 070d459..749591f 100644 --- a/route53-healthcheck.tf +++ b/route53-healthcheck.tf @@ -1,5 +1,4 @@ resource "aws_route53_health_check" "default" { - # reference_name = var.name fqdn = var.hostname port = var.port type = var.protocol @@ -8,6 +7,7 @@ resource "aws_route53_health_check" "default" { request_interval = var.request_interval measure_latency = var.measure_latency #insufficient_data_health_status = "Healthy" + # reference_name = var.name tags = { Name = var.hostname From a6d25fd6a6a009ccbdef905fb23b8219d0a765de Mon Sep 17 00:00:00 2001 From: "edson.siqueira@dnx.solutions" Date: Fri, 17 Jun 2022 14:49:00 -0300 Subject: [PATCH 5/5] Fixing fmt and missing comment provider --- examples/route53_health_check.tf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/route53_health_check.tf b/examples/route53_health_check.tf index 65c7aea..4222938 100644 --- a/examples/route53_health_check.tf +++ b/examples/route53_health_check.tf @@ -1,13 +1,13 @@ module "terraform-aws-route53healthcheck" { source = "git::https://github.com/DNXLabs/terraform-aws-route53healthcheck.git?ref=0.1.1" for_each = { for healthcheck in try(local.workspace.route53_health_check.endpoint, []) : healthcheck.hostname => healthcheck } - providers = { - aws = aws.us-east-1 - } + # providers = { + # aws = aws.us-east-1 + # } - hostname = try(each.value.hostname, "[]") - port = try(each.value.port, 443 ) - protocol = try(each.value.protocol, "HTTPS" ) - healthcheck_path = try(each.value.healthcheck_path, "") - measure_latency = try(each.value.measure_latency, true) + hostname = try(each.value.hostname, "[]") + port = try(each.value.port, 443) + protocol = try(each.value.protocol, "HTTPS") + healthcheck_path = try(each.value.healthcheck_path, "") + measure_latency = try(each.value.measure_latency, true) } \ No newline at end of file