Skip to content

Commit

Permalink
Merge pull request #6 from DNXLabs/dnx_update
Browse files Browse the repository at this point in the history
Changing variables and adding examples after some tests with this module
  • Loading branch information
soareseds committed Jun 21, 2022
2 parents 72afa57 + a6d25fd commit 7735f3b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
3 changes: 2 additions & 1 deletion 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"
Expand Down
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -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

Expand Down
23 changes: 17 additions & 6 deletions _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"
Expand All @@ -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
}
21 changes: 21 additions & 0 deletions 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:
13 changes: 13 additions & 0 deletions 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)
}
9 changes: 5 additions & 4 deletions route53-healthcheck.tf
@@ -1,14 +1,15 @@
resource "aws_route53_health_check" "default" {
reference_name = var.name
fqdn = var.hostname
port = var.port
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"
# reference_name = var.name

tags = {
Name = var.name
Name = var.hostname
}
}
}

0 comments on commit 7735f3b

Please sign in to comment.