From 645ad12e7ab2a1d19dd2e839ba00951b0b500d4e Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Sat, 22 May 2021 22:36:46 -0500 Subject: [PATCH 1/2] Changes name to logdna_id to prevent lookup issues Signed-off-by: Sean Sundberg --- main.tf | 25 +++++-------------------- module.yaml | 4 ++-- test/stages/stage-logdna-bind.tf | 2 +- variables.tf | 4 ++-- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/main.tf b/main.tf index 96d0395..0ab3337 100644 --- a/main.tf +++ b/main.tf @@ -1,10 +1,9 @@ locals { tmp_dir = "${path.cwd}/.tmp" - name = var.name role = "Manager" - bind = var.name != "" && var.cluster_name != "" cluster_type_file = "${local.tmp_dir}/cluster_type.out" cluster_type = data.local_file.cluster_type.content + bind = true } resource null_resource print_names { @@ -12,10 +11,6 @@ resource null_resource print_names { provisioner "local-exec" { command = "echo 'Resource group name: ${var.resource_group_name}'" } - - provisioner "local-exec" { - command = "echo 'LogDNA instance: ${local.name}'" - } } data "ibm_resource_group" "tools_resource_group" { @@ -24,21 +19,11 @@ data "ibm_resource_group" "tools_resource_group" { name = var.resource_group_name } -data "ibm_resource_instance" "logdna_instance" { - count = local.bind ? 1 : 0 - depends_on = [null_resource.print_names] - - name = local.name - resource_group_id = data.ibm_resource_group.tools_resource_group.id - location = var.region - service = "logdna" -} - resource "ibm_resource_key" "logdna_instance_key" { count = local.bind ? 1 : 0 - name = "${local.name}-key" - resource_instance_id = data.ibm_resource_instance.logdna_instance[0].id + name = "${var.cluster_name}-key" + resource_instance_id = var.logdna_id role = local.role //User can increase timeouts @@ -66,11 +51,11 @@ resource "null_resource" "setup-ob-plugin" { resource "null_resource" "logdna_bind" { count = local.bind ? 1 : 0 - depends_on = [null_resource.setup-ob-plugin,null_resource.ibmcloud_login] + depends_on = [null_resource.setup-ob-plugin, null_resource.ibmcloud_login] triggers = { cluster_id = var.cluster_id - instance_id = data.ibm_resource_instance.logdna_instance[0].guid + instance_id = var.logdna_id kubeconfig = var.cluster_config_file_path } diff --git a/module.yaml b/module.yaml index 47fe4f5..5eda0a2 100644 --- a/module.yaml +++ b/module.yaml @@ -66,10 +66,10 @@ versions: id: sysdig_bind output: sync optional: true - - name: name + - name: logdna_id moduleRef: id: logdna - output: name + output: id - name : region scope: global - name : private_endpoint diff --git a/test/stages/stage-logdna-bind.tf b/test/stages/stage-logdna-bind.tf index 6121bb1..e8f08d3 100644 --- a/test/stages/stage-logdna-bind.tf +++ b/test/stages/stage-logdna-bind.tf @@ -8,5 +8,5 @@ module "logdna-bind" { cluster_name = module.dev_cluster.name cluster_config_file_path = module.dev_cluster.platform.kubeconfig tools_namespace = module.dev_tools_namespace.name - name = module.logdna.name + logdna_id = module.logdna.id } diff --git a/variables.tf b/variables.tf index 90bf645..5a5b691 100644 --- a/variables.tf +++ b/variables.tf @@ -13,9 +13,9 @@ variable "ibmcloud_api_key" { description = "The apikey used to access the IBM Cloud account" } -variable "name" { +variable "logdna_id" { type = string - description = "The name that should be used for the service, particularly when connecting to an existing service. If not provided then the name will be defaulted to {name prefix}-{service}" + description = "The id of the logdna instance that will be gound to the cluster" default = "" } From d5681283b5a89193089d605fa2836f97fca881d5 Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Sat, 22 May 2021 22:47:09 -0500 Subject: [PATCH 2/2] Uses guid output from logdna instead of id Signed-off-by: Sean Sundberg --- module.yaml | 2 +- test/stages/stage-logdna-bind.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module.yaml b/module.yaml index 5eda0a2..5a70fb9 100644 --- a/module.yaml +++ b/module.yaml @@ -69,7 +69,7 @@ versions: - name: logdna_id moduleRef: id: logdna - output: id + output: guid - name : region scope: global - name : private_endpoint diff --git a/test/stages/stage-logdna-bind.tf b/test/stages/stage-logdna-bind.tf index e8f08d3..04d27eb 100644 --- a/test/stages/stage-logdna-bind.tf +++ b/test/stages/stage-logdna-bind.tf @@ -8,5 +8,5 @@ module "logdna-bind" { cluster_name = module.dev_cluster.name cluster_config_file_path = module.dev_cluster.platform.kubeconfig tools_namespace = module.dev_tools_namespace.name - logdna_id = module.logdna.id + logdna_id = module.logdna.guid }