From 1a86398175ae6bcb783dc5448032c6f249190b49 Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:25:56 +0200 Subject: [PATCH 1/6] Add http call after cluster installation. --- modules/firstmate/sync/main.tf | 30 ++++++++++++++++ modules/firstmate/sync/outputs.tf | 4 +++ modules/firstmate/sync/variables.tf | 36 +++++++++++++++++++ .../kubernetes/firstmate-monitoring/main.tf | 15 +++++++- .../firstmate-monitoring/variables.tf | 1 + 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 modules/firstmate/sync/main.tf create mode 100644 modules/firstmate/sync/outputs.tf create mode 100644 modules/firstmate/sync/variables.tf 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..a5e25e8 --- /dev/null +++ b/modules/firstmate/sync/variables.tf @@ -0,0 +1,36 @@ +variable "baseUrl" { + description = "Baseurl of firstmate" + type = string +# default = "api.eu.firstmate.cloud/api/v1/sync" + default = "localhost:3000/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 + default = jsonencode({ + cluster = { + name = "test" + } + }) +} + + +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..4ef4e30 100644 --- a/modules/kubernetes/firstmate-monitoring/main.tf +++ b/modules/kubernetes/firstmate-monitoring/main.tf @@ -55,4 +55,17 @@ 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=0.0.10" + depends_on = [helm_release.firstmate_monitoring_release] + api_key = var.api_key + body = jsonencode({ + cluster = { + name = var.cluster_name + version = var.kube_config.version + } + }) + path = "kubernetes-monitoring" +} diff --git a/modules/kubernetes/firstmate-monitoring/variables.tf b/modules/kubernetes/firstmate-monitoring/variables.tf index 03ebdfa..c936453 100644 --- a/modules/kubernetes/firstmate-monitoring/variables.tf +++ b/modules/kubernetes/firstmate-monitoring/variables.tf @@ -5,6 +5,7 @@ variable "kube_config" { client_certificate = string client_key = string cluster_ca_certificate = string + version = string }) } From ca2fb4aa77d3a23ad99b1e2f4fa505b1cc7719af Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:27:42 +0200 Subject: [PATCH 2/6] Add http call after cluster installation. --- modules/kubernetes/firstmate-monitoring/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kubernetes/firstmate-monitoring/main.tf b/modules/kubernetes/firstmate-monitoring/main.tf index 4ef4e30..dfd5404 100644 --- a/modules/kubernetes/firstmate-monitoring/main.tf +++ b/modules/kubernetes/firstmate-monitoring/main.tf @@ -58,7 +58,7 @@ resource "helm_release" "firstmate_monitoring_release" { } module "sync" { - source = "git::git@github.com:firstmatecloud/firstmate-terraform-modules.git//modules/firstmate/sync?ref=0.0.10" + 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({ From a85be5a92d77ae334b9c1e9f290f19fc73c78501 Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:29:21 +0200 Subject: [PATCH 3/6] Add http call after cluster installation. --- modules/firstmate/sync/variables.tf | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/firstmate/sync/variables.tf b/modules/firstmate/sync/variables.tf index a5e25e8..c3ed193 100644 --- a/modules/firstmate/sync/variables.tf +++ b/modules/firstmate/sync/variables.tf @@ -20,11 +20,7 @@ variable "method" { variable "body" { description = "body of request" type = string - default = jsonencode({ - cluster = { - name = "test" - } - }) + } From 026b61ae378d124781f72a8d2a55e7bf3b1fc69d Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:30:56 +0200 Subject: [PATCH 4/6] Add http call after cluster installation. --- modules/kubernetes/firstmate-monitoring/main.tf | 1 - modules/kubernetes/firstmate-monitoring/variables.tf | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/kubernetes/firstmate-monitoring/main.tf b/modules/kubernetes/firstmate-monitoring/main.tf index dfd5404..0d2a6e4 100644 --- a/modules/kubernetes/firstmate-monitoring/main.tf +++ b/modules/kubernetes/firstmate-monitoring/main.tf @@ -64,7 +64,6 @@ module "sync" { body = jsonencode({ cluster = { name = var.cluster_name - version = var.kube_config.version } }) path = "kubernetes-monitoring" diff --git a/modules/kubernetes/firstmate-monitoring/variables.tf b/modules/kubernetes/firstmate-monitoring/variables.tf index c936453..03ebdfa 100644 --- a/modules/kubernetes/firstmate-monitoring/variables.tf +++ b/modules/kubernetes/firstmate-monitoring/variables.tf @@ -5,7 +5,6 @@ variable "kube_config" { client_certificate = string client_key = string cluster_ca_certificate = string - version = string }) } From c0cf52d22654252bddd13923dd60f757ac462f97 Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:32:26 +0200 Subject: [PATCH 5/6] Add http call after cluster installation. --- modules/firstmate/sync/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/firstmate/sync/variables.tf b/modules/firstmate/sync/variables.tf index c3ed193..d45a23f 100644 --- a/modules/firstmate/sync/variables.tf +++ b/modules/firstmate/sync/variables.tf @@ -1,8 +1,8 @@ variable "baseUrl" { description = "Baseurl of firstmate" type = string -# default = "api.eu.firstmate.cloud/api/v1/sync" - default = "localhost:3000/api/v1/tfsync" +# default = "https://api.eu.firstmate.cloud/api/v1/sync" + default = "http://localhost:3000/api/v1/tfsync" } variable "path" { From fb4d575565b180d375d3c1f343a392bbb8f4f07f Mon Sep 17 00:00:00 2001 From: desyco Date: Wed, 26 Jun 2024 15:33:03 +0200 Subject: [PATCH 6/6] Add http call after cluster installation. --- modules/firstmate/sync/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/firstmate/sync/variables.tf b/modules/firstmate/sync/variables.tf index d45a23f..d66c72f 100644 --- a/modules/firstmate/sync/variables.tf +++ b/modules/firstmate/sync/variables.tf @@ -2,7 +2,7 @@ variable "baseUrl" { description = "Baseurl of firstmate" type = string # default = "https://api.eu.firstmate.cloud/api/v1/sync" - default = "http://localhost:3000/api/v1/tfsync" + default = "http://localhost:8080/api/v1/tfsync" } variable "path" {