diff --git a/modules/firstmate/sync/main.tf b/modules/firstmate/sync/main.tf new file mode 100644 index 0000000..6ae4037 --- /dev/null +++ b/modules/firstmate/sync/main.tf @@ -0,0 +1,30 @@ +terraform { + required_providers { + helm = { + source = "hashicorp/helm" + version = "=2.14.0" + } + kubernetes = { + source = "hashicorp/kubernetes" + version = "=2.3.1" + } + } +} + +locals { + url = "${var.baseUrl}/${var.path}" +} + +data "http" "sync" { + url = local.url + method = var.method + + request_headers = { + Accept = "application/json" + authorization = var.api_key + } + # Optional request body + request_body = var.body +} + + diff --git a/modules/firstmate/sync/outputs.tf b/modules/firstmate/sync/outputs.tf new file mode 100644 index 0000000..8ce2680 --- /dev/null +++ b/modules/firstmate/sync/outputs.tf @@ -0,0 +1,4 @@ +output "status_code" { + description = "The status code of the request" + value = data.http.sync.status_code +} \ No newline at end of file diff --git a/modules/firstmate/sync/variables.tf b/modules/firstmate/sync/variables.tf new file mode 100644 index 0000000..d66c72f --- /dev/null +++ b/modules/firstmate/sync/variables.tf @@ -0,0 +1,32 @@ +variable "baseUrl" { + description = "Baseurl of firstmate" + type = string +# default = "https://api.eu.firstmate.cloud/api/v1/sync" + default = "http://localhost:8080/api/v1/tfsync" +} + +variable "path" { + description = "path of the request" + type = string + default = "kubernetes-monitoring" +} + +variable "method" { + description = "Baseurl of firstmate" + type = string + default = "POST" +} + +variable "body" { + description = "body of request" + type = string + +} + + +variable "api_key" { + description = "Firstmate Api key" + type = string +} + + diff --git a/modules/kubernetes/firstmate-monitoring/main.tf b/modules/kubernetes/firstmate-monitoring/main.tf index cb690fa..0d2a6e4 100644 --- a/modules/kubernetes/firstmate-monitoring/main.tf +++ b/modules/kubernetes/firstmate-monitoring/main.tf @@ -55,4 +55,16 @@ resource "helm_release" "firstmate_monitoring_release" { name = "permissions.scalingMetrics" value = var.permissions.scalingMetrics } -} \ No newline at end of file +} + +module "sync" { + source = "git::git@github.com:firstmatecloud/firstmate-terraform-modules.git//modules/firstmate/sync?ref=add-http-call" + depends_on = [helm_release.firstmate_monitoring_release] + api_key = var.api_key + body = jsonencode({ + cluster = { + name = var.cluster_name + } + }) + path = "kubernetes-monitoring" +}