Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: support health check logging #283

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ resource "google_compute_health_check" "http" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}

resource "google_compute_health_check" "tcp" {
Expand All @@ -236,4 +240,8 @@ resource "google_compute_health_check" "tcp" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}
2 changes: 2 additions & 0 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ variable "health_check" {
request = string
request_path = string
host = string
enable_logging = bool
})
default = {
type = ""
Expand All @@ -144,6 +145,7 @@ variable "health_check" {
request = ""
request_path = "/"
host = ""
enable_logging = false
}
}

Expand Down
4 changes: 2 additions & 2 deletions autogen/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google-beta = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
google-beta = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v7.9.0"
Expand Down
2 changes: 2 additions & 0 deletions examples/mig/full/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ variable "health_check" {
request = string
request_path = string
host = string
enable_logging = string
})
default = {
type = "http"
Expand All @@ -231,6 +232,7 @@ variable "health_check" {
request = ""
request_path = "/"
host = ""
enable_logging = false
}
}

Expand Down
1 change: 1 addition & 0 deletions examples/mig/healthcheck/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ module "mig" {
request = ""
request_path = "/"
host = "localhost"
enable_logging = false
}
}
2 changes: 1 addition & 1 deletion examples/mig/healthcheck/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "~> 2.2"
version = "~> 3.4"
}
}
}
2 changes: 1 addition & 1 deletion modules/compute_disk_snapshot/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
null = ">= 2.1"
}
provider_meta "google" {
Expand Down
2 changes: 1 addition & 1 deletion modules/compute_instance/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v7.9.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/instance_template/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:instance_template/v7.9.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The current version is 2.X. The following guides are available to assist with up
| autoscaling\_scale\_in\_control | Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control | <pre>object({<br> fixed_replicas = number<br> percent_replicas = number<br> time_window_sec = number<br> })</pre> | <pre>{<br> "fixed_replicas": null,<br> "percent_replicas": null,<br> "time_window_sec": null<br>}</pre> | no |
| cooldown\_period | The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. | `number` | `60` | no |
| distribution\_policy\_zones | The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. | `list(string)` | `[]` | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> initial_delay_sec = number<br> check_interval_sec = number<br> healthy_threshold = number<br> timeout_sec = number<br> unhealthy_threshold = number<br> response = string<br> proxy_header = string<br> port = number<br> request = string<br> request_path = string<br> host = string<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> initial_delay_sec = number<br> check_interval_sec = number<br> healthy_threshold = number<br> timeout_sec = number<br> unhealthy_threshold = number<br> response = string<br> proxy_header = string<br> port = number<br> request = string<br> request_path = string<br> host = string<br> enable_logging = bool<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "enable_logging": false,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no |
| hostname | Hostname prefix for instances | `string` | `"default"` | no |
| instance\_template | Instance template self\_link used to create compute instances | `any` | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions modules/mig/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ resource "google_compute_health_check" "http" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}

resource "google_compute_health_check" "tcp" {
Expand All @@ -216,4 +220,8 @@ resource "google_compute_health_check" "tcp" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}
2 changes: 2 additions & 0 deletions modules/mig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ variable "health_check" {
request = string
request_path = string
host = string
enable_logging = bool
})
default = {
type = ""
Expand All @@ -129,6 +130,7 @@ variable "health_check" {
request = ""
request_path = "/"
host = ""
enable_logging = false
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/mig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google-beta = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
google-beta = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:mig/v7.9.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/mig_with_percent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The current version is 2.X. The following guides are available to assist with up
| autoscaling\_scale\_in\_control | Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control | <pre>object({<br> fixed_replicas = number<br> percent_replicas = number<br> time_window_sec = number<br> })</pre> | <pre>{<br> "fixed_replicas": null,<br> "percent_replicas": null,<br> "time_window_sec": null<br>}</pre> | no |
| cooldown\_period | The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. | `number` | `60` | no |
| distribution\_policy\_zones | The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. | `list(string)` | `[]` | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> initial_delay_sec = number<br> check_interval_sec = number<br> healthy_threshold = number<br> timeout_sec = number<br> unhealthy_threshold = number<br> response = string<br> proxy_header = string<br> port = number<br> request = string<br> request_path = string<br> host = string<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> initial_delay_sec = number<br> check_interval_sec = number<br> healthy_threshold = number<br> timeout_sec = number<br> unhealthy_threshold = number<br> response = string<br> proxy_header = string<br> port = number<br> request = string<br> request_path = string<br> host = string<br> enable_logging = bool<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "enable_logging": false,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no |
| hostname | Hostname prefix for instances | `string` | `"default"` | no |
| instance\_template\_initial\_version | Instance template self\_link used to create compute instances for the initial version | `any` | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions modules/mig_with_percent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ resource "google_compute_health_check" "http" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}

resource "google_compute_health_check" "tcp" {
Expand All @@ -227,4 +231,8 @@ resource "google_compute_health_check" "tcp" {
response = var.health_check["response"]
proxy_header = var.health_check["proxy_header"]
}

log_config {
enable = var.health_check["enable_logging"]
}
}
2 changes: 2 additions & 0 deletions modules/mig_with_percent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ variable "health_check" {
request = string
request_path = string
host = string
enable_logging = bool
})
default = {
type = ""
Expand All @@ -137,6 +138,7 @@ variable "health_check" {
request = ""
request_path = "/"
host = ""
enable_logging = false
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/mig_with_percent/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google-beta = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
google-beta = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v7.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google-beta = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
google-beta = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v7.9.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/umig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.43, < 5.0"
google = ">= 3.71, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:umig/v7.9.0"
Expand Down
6 changes: 3 additions & 3 deletions test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.0, < 5.0"
version = ">= 3.71, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.0, < 5.0"
version = ">= 3.71, < 5.0"
}
null = {
source = "hashicorp/null"
version = "~> 2.1"
}
random = {
source = "hashicorp/random"
version = "~> 2.2"
version = "~> 3.4"
}
}
}