最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Is there any way the Terraform DBX Exporter can export the MS Teams URL of the databricks_notification_destination? - Stack Over

programmeradmin6浏览0评论

I have some job notifications setup via MS Teams URL. Tried to export the entire workspace even with the -export-secrets option but in the config files generated under the settings.tf file, the URL variables have been assigned but the values of the variables have not been generated. Do I have to manually enter them or is there any way to get the exporter to generate those values also?

resource "databricks_notification_destination" "example1" {   display_name = "Platform Example"   
config {     
    microsoft_teams {       
         url = var.config_example1     
     }   
   } 
}

Tried using the -export-secrets option but to no avail.

I have some job notifications setup via MS Teams URL. Tried to export the entire workspace even with the -export-secrets option but in the config files generated under the settings.tf file, the URL variables have been assigned but the values of the variables have not been generated. Do I have to manually enter them or is there any way to get the exporter to generate those values also?

resource "databricks_notification_destination" "example1" {   display_name = "Platform Example"   
config {     
    microsoft_teams {       
         url = var.config_example1     
     }   
   } 
}

Tried using the -export-secrets option but to no avail.

Share Improve this question edited Feb 6 at 9:37 Jahnavi 7,9231 gold badge6 silver badges12 bronze badges Recognized by Microsoft Azure Collective asked Feb 5 at 11:57 KerbecsKerbecs 11 bronze badge 5
  • Have you tried any code so far! @Kerbecs – Jahnavi Commented Feb 5 at 12:44
  • @Jahnavi since its a huge workspace, I was just trying to use the experimental resource exporter with the export-secrets option enabled. It generated the config files for me but some variables (all related to the MS Teams URL) dont have values listed in the terraform.tfvars file. – Kerbecs Commented Feb 5 at 14:18
  • Ok. If possible, share the sample template to work on and it helps to understand the issue better. @Kerbecs – Jahnavi Commented Feb 6 at 3:27
  • 1 Sure, so for example this was generated by the exporter. resource "databricks_notification_destination" "example1" { display_name = "Platform Example" config { microsoft_teams { url = var.config_example1 } } } Now what I want is the var.config_example1 value to be generated by the exporter as well. variable "config_example1" { description = "" } This is how it looks like in my vars.tf and the value for the same isn't present in terraform.tfvars file also. I am quite new to Terraform so sorry if I can't explain much better. @Jahnavi – Kerbecs Commented Feb 6 at 4:18
  • Have you tried using databricks_secret_resource? @Kerbecs – Jahnavi Commented Feb 7 at 12:48
Add a comment  | 

1 Answer 1

Reset to default 0

Do I have to manually enter them or is there any way to get the exporter to generate those values also?

There are a couple of approaches you can follow here to retrieve the notification secret value. Firstly, you can visit the workspace path Databricks workspace >> settings >> Notifications >> Url and copy the specific team's notifications URL. Now store that secret value in a variable using terraform variable block and access the value in the code.

variable "urlval" {
 type = string
 default = "https://outlook.office.com/"
}

Note: To access and retrieve the value in the main.tf, you can use var.urlval.

Alternatively, you can use databricks_secret resource available in Terraform.

With this resource you can insert a secret under the provided scope with the given name.

First step is to store the secret value in a key vault secret as shown below by setting up the expiration date as per your requirement.

terraform {
  required_providers {
    databricks = {
      source = "databricks/databricks"
      version = "1.65.1"
    }
  }
}

provider "databricks" {
features{}
}
provider "azurerm"{
features{}
subscription_id="xxxx"
}
data "azurerm_key_vault" "example" {
  name                = "carokeyv"
  resource_group_name = "caronew"
}
data "azurerm_key_vault_secret" "example" {
  name         = "databrickssecret"
  key_vault_id = data.azurerm_key_vault.example.id
}
resource "databricks_secret_scope" "scope" {
  name = "xxxx"
}
resource "databricks_secret" "secret" {
  key          = "MicrosoftTeams"
  string_value = data.azurerm_key_vault_secret.example.value
  scope        = databricks_secret_scope.scope.id
}
output "notification_url" {
 value = nonsensitive(databricks_secret.secret.string_value)
}

Note: You can store it in the databricks_secret resource or directly reference the value from the key vault secret.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论