Skip to content

Commit

Permalink
MON-459: Bump to HCL 2 syntax / tf 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Shr3ps authored and xp-1000 committed Jul 2, 2019
1 parent d82101c commit b093f2f
Show file tree
Hide file tree
Showing 288 changed files with 6,115 additions and 5,971 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before_script:
- apk add --no-cache curl

auto_update:
image: hashicorp/terraform:0.11.14
image: hashicorp/terraform:0.12.1
stage: test
script:
- apk add --no-cache bash git grep coreutils
Expand Down
9 changes: 5 additions & 4 deletions caas/kubernetes/ark/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,30 @@ variable "prefix_slug" {

variable "ark_schedules_monitor_message" {
description = "Custom message for Ark schedules monitor"
type = "string"
type = string
default = ""
}

variable "ark_schedules_monitor_timeframe" {
description = "Monitor timeframe for Ark schedules monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string"
type = string
default = "last_1d"
}

variable "ark_schedules_enabled" {
description = "Flag to enable Ark schedules monitor"
type = "string"
type = string
default = "true"
}

variable "ark_schedules_extra_tags" {
description = "Extra tags for Ark schedules monitor"
type = "list"
type = list(string)
default = []
}

variable "ark_schedules_monitor_no_data_timeframe" {
description = "No data timeframe in minutes"
default = 1440
}

9 changes: 5 additions & 4 deletions caas/kubernetes/ark/modules.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module "filter-tags" {
source = "../../../common/filter-tags"

environment = "${var.environment}"
environment = var.environment
resource = "ark"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
}

31 changes: 16 additions & 15 deletions caas/kubernetes/ark/monitors-ark.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
resource "datadog_monitor" "ark_schedules_monitor" {
count = "${var.ark_schedules_enabled == "true" ? 1 : 0}"
count = var.ark_schedules_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Ark backup failed"
type = "query alert"
message = "${coalesce(var.ark_schedules_monitor_message, var.message)}"
message = coalesce(var.ark_schedules_monitor_message, var.message)

query = <<EOQ
sum(${var.ark_schedules_monitor_timeframe}):min:ark.ark_backup_failure_total${module.filter-tags.query_alert} by {schedule}.as_count() > 1
EOQ
EOQ

thresholds {
thresholds = {
critical = 1
warning = 0
warning = 0
}

evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}"
no_data_timeframe = "${var.ark_schedules_monitor_no_data_timeframe}"
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
no_data_timeframe = var.ark_schedules_monitor_no_data_timeframe

notify_no_data = true
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
notify_no_data = true
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false

tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:ark", "team:claranet", "created-by:terraform", "${var.ark_schedules_extra_tags}"]
tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:ark", "team:claranet", "created-by:terraform", var.ark_schedules_extra_tags]
}

3 changes: 2 additions & 1 deletion caas/kubernetes/ark/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
output "ark_schedules_monitor_id" {
description = "id for monitor ark_schedules_monitor"
value = "${datadog_monitor.ark_schedules_monitor.*.id}"
value = datadog_monitor.ark_schedules_monitor.*.id
}

4 changes: 4 additions & 0 deletions caas/kubernetes/ark/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
9 changes: 5 additions & 4 deletions caas/kubernetes/cluster/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,25 @@ variable "prefix_slug" {

variable "apiserver_enabled" {
description = "Flag to enable API server monitor"
type = "string"
type = string
default = "true"
}

variable "apiserver_extra_tags" {
description = "Extra tags for API server monitor"
type = "list"
type = list(string)
default = []
}

variable "apiserver_message" {
description = "Custom message for API server monitor"
type = "string"
type = string
default = ""
}

variable "apiserver_threshold_warning" {
description = "API server monitor (warning threshold)"
type = "string"
type = string
default = 3
}

9 changes: 5 additions & 4 deletions caas/kubernetes/cluster/modules.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module "filter-tags" {
source = "../../../common/filter-tags"

environment = "${var.environment}"
environment = var.environment
resource = "kubernetes"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
}

25 changes: 13 additions & 12 deletions caas/kubernetes/cluster/monitors-k8s-cluster.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
resource "datadog_monitor" "apiserver" {
count = "${var.apiserver_enabled == "true" ? 1 : 0}"
count = var.apiserver_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes API server does not respond"
message = "${coalesce(var.apiserver_message, var.message)}"
message = coalesce(var.apiserver_message, var.message)

type = "service check"

query = <<EOQ
"kube_apiserver_controlplane.up"${module.filter-tags.service_check}.last(6).count_by_status()
EOQ
EOQ

thresholds = {
warning = "${var.apiserver_threshold_warning}"
warning = var.apiserver_threshold_warning
critical = 5
}

new_host_delay = "${var.new_host_delay}"
notify_no_data = true
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
new_host_delay = var.new_host_delay
notify_no_data = true
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true

tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", "${var.apiserver_extra_tags}"]
tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", var.apiserver_extra_tags]
}

3 changes: 2 additions & 1 deletion caas/kubernetes/cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
output "apiserver_id" {
description = "id for monitor apiserver"
value = "${datadog_monitor.apiserver.*.id}"
value = datadog_monitor.apiserver.*.id
}

4 changes: 4 additions & 0 deletions caas/kubernetes/cluster/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
27 changes: 14 additions & 13 deletions caas/kubernetes/ingress/vts/inputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Global Terraform
variable "environment" {
description = "Architecture Environment"
type = "string"
type = string
}

# Global DataDog
Expand Down Expand Up @@ -43,13 +43,13 @@ variable "filter_tags_custom_excluded" {

variable "ingress_5xx_enabled" {
description = "Flag to enable Ingress 5xx errors monitor"
type = "string"
type = string
default = "true"
}

variable "ingress_5xx_extra_tags" {
description = "Extra tags for Ingress 5xx errors monitor"
type = "list"
type = list(string)
default = []
}

Expand All @@ -60,37 +60,37 @@ variable "ingress_5xx_message" {

variable "ingress_5xx_time_aggregator" {
description = "Monitor aggregator for Ingress 5xx errors [available values: min, max or avg]"
type = "string"
type = string
default = "min"
}

variable "ingress_5xx_timeframe" {
description = "Monitor timeframe for Ingress 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string"
type = string
default = "last_5m"
}

variable "ingress_5xx_threshold_critical" {
type = "string"
type = string
default = "20"
description = "5xx critical threshold in percentage"
}

variable "ingress_5xx_threshold_warning" {
type = "string"
type = string
default = "10"
description = "5xx warning threshold in percentage"
}

variable "ingress_4xx_enabled" {
description = "Flag to enable Ingress 4xx errors monitor"
type = "string"
type = string
default = "true"
}

variable "ingress_4xx_extra_tags" {
description = "Extra tags for Ingress 4xx errors monitor"
type = "list"
type = list(string)
default = []
}

Expand All @@ -101,24 +101,24 @@ variable "ingress_4xx_message" {

variable "ingress_4xx_time_aggregator" {
description = "Monitor aggregator for Ingress 4xx errors [available values: min, max or avg]"
type = "string"
type = string
default = "min"
}

variable "ingress_4xx_timeframe" {
description = "Monitor timeframe for Ingress 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string"
type = string
default = "last_5m"
}

variable "ingress_4xx_threshold_critical" {
type = "string"
type = string
default = "40"
description = "4xx critical threshold in percentage"
}

variable "ingress_4xx_threshold_warning" {
type = "string"
type = string
default = "20"
description = "4xx warning threshold in percentage"
}
Expand All @@ -127,3 +127,4 @@ variable "artificial_requests_count" {
default = 5
description = "Number of false requests used to mitigate false positive in case of low trafic"
}

25 changes: 13 additions & 12 deletions caas/kubernetes/ingress/vts/modules.tf
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
module "filter-tags" {
source = "../../../../common/filter-tags"

environment = "${var.environment}"
environment = var.environment
resource = "ingress"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
extra_tags_excluded = ["upstream:upstream-default-backend"]
}

module "filter-tags-5xx" {
source = "../../../../common/filter-tags"

environment = "${var.environment}"
environment = var.environment
resource = "ingress"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
extra_tags = ["status_code:5xx"]
extra_tags_excluded = ["upstream:upstream-default-backend"]
}

module "filter-tags-4xx" {
source = "../../../../common/filter-tags"

environment = "${var.environment}"
environment = var.environment
resource = "ingress"
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
filter_tags_custom = "${var.filter_tags_custom}"
filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}"
filter_tags_use_defaults = var.filter_tags_use_defaults
filter_tags_custom = var.filter_tags_custom
filter_tags_custom_excluded = var.filter_tags_custom_excluded
extra_tags = ["status_code:4xx"]
extra_tags_excluded = ["upstream:upstream-default-backend"]
}

Loading

0 comments on commit b093f2f

Please sign in to comment.