Skip to content
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
25 changes: 5 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
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 {

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" {
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ versions:
id: sysdig_bind
output: sync
optional: true
- name: name
- name: logdna_id
moduleRef:
id: logdna
output: name
output: guid
- name : region
scope: global
- name : private_endpoint
Expand Down
2 changes: 1 addition & 1 deletion test/stages/stage-logdna-bind.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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.guid
}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}

Expand Down