Skip to content

Commit 79f9372

Browse files
committed
initial commit
1 parent 662ff35 commit 79f9372

File tree

10 files changed

+147
-23
lines changed

10 files changed

+147
-23
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ _testmain.go
8181

8282
# ignore test related file(s)
8383
**/test**
84-
**.
84+
**.

examples/sample/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
variable "teamid" {
22
description = "(Required) Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply'"
3-
type = string
3+
type = string
44
}
55

66
variable "prjid" {
77
description = "(Required) Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply'"
8-
type = string
8+
type = string
99
}

locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ locals {
33
{
44
"Name" = "${var.teamid}-${var.prjid}",
55
"team" = var.teamid,
6-
"project" = var.prjid
6+
"project" = var.prjid,
7+
"Owner" = lookup(data.external.current_user.result, "name")
78
}
89
)
910
}
10-

main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data "azurerm_client_config" "current" {
2+
}
3+
4+
data "external" "current_user" {
5+
program = ["az", "account", "show", "--query", "user"]
6+
}

outputs.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "databricks_host" {
2+
description = "databricks workspace url"
3+
value = "https://${azurerm_databricks_workspace.this.workspace_url}/"
4+
}
5+
6+
output "resource_group_name" {
7+
description = "databricks resource group name"
8+
value = azurerm_databricks_workspace.this.resource_group_name
9+
}
10+
11+
output "managed_resource_group_name" {
12+
description = "databricks managed resource group name"
13+
value = azurerm_databricks_workspace.this.managed_resource_group_name
14+
}
15+
16+
output "databricks_workspace_id" {
17+
description = "databricks workspace id"
18+
value = azurerm_databricks_workspace.this.workspace_id
19+
}

providers.tf

Lines changed: 0 additions & 17 deletions
This file was deleted.

resource_group.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "azurerm_resource_group" "this" {
2+
count = var.deploy_rg != null
3+
4+
name = var.rg_name != null ? var.rg_name : "${var.teamid}-${var.prjid}"
5+
location = var.region
6+
tags = var.custom_tags != null ? merge(var.custom_tags, local.shared_tags) : merge(local.shared_tags)
7+
}

variables.tf

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
11
variable "teamid" {
22
description = "(Required) Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply'"
3+
type = string
34
}
45

56
variable "prjid" {
67
description = "(Required) Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply'"
8+
type = string
9+
}
10+
11+
variable "region" {
12+
description = "default Azure region"
13+
type = string
14+
default = "westeurope"
15+
}
16+
17+
variable "databricks_account_username" {
18+
description = "databricks account username"
19+
type = string
20+
}
21+
variable "databricks_account_password" {
22+
description = "databricks account password"
23+
type = string
24+
}
25+
26+
variable "databricks_account_id" {
27+
description = "External ID provided by third party."
28+
type = string
29+
}
30+
31+
resource "random_string" "naming" {
32+
special = false
33+
upper = false
34+
length = 3
35+
}
36+
37+
locals {
38+
suffix = random_string.naming.result
39+
}
40+
41+
variable "rg_name" {
42+
description = "Resource Group name"
43+
default = null
44+
type = string
45+
}
46+
47+
variable "workspace_name" {
48+
description = "Databricks workspace name"
49+
default = null
50+
type = string
51+
}
52+
53+
variable "sku" {
54+
description = "Databricks sku"
55+
default = "premium"
56+
type = string
757
}
858

59+
960
variable "subscription_id" {
1061
description = "Azure subscription Id"
1162
type = string
@@ -24,4 +75,16 @@ variable "client_secret" {
2475
variable "tenant_id" {
2576
description = "Azure tenant Id"
2677
type = string
27-
}
78+
}
79+
80+
variable "custom_tags" {
81+
type = any
82+
description = "Extra custom tags"
83+
default = null
84+
}
85+
86+
variable "deploy_rg" {
87+
description = "deploy resource group"
88+
type = bool
89+
default = false
90+
}

versions.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
terraform {
2+
required_version = ">= 1.0.1"
3+
required_providers {
4+
azure = {
5+
version = "~> 2.33"
6+
}
7+
azurerm = {
8+
version = "~> 2.94"
9+
}
10+
databricks = {
11+
source = "databrickslabs/databricks"
12+
version = "0.3.5"
13+
}
14+
random = {
15+
version = "~> 3.1"
16+
}
17+
time = {
18+
version = "~> 0.7"
19+
}
20+
external = {
21+
version = "~> 2.2"
22+
}
23+
}
24+
}
25+
26+
provider "databricks" {
27+
host = "https://accounts.cloud.databricks.com"
28+
username = var.databricks_account_username
29+
password = var.databricks_account_password
30+
}
31+
32+
provider "azurerm" {
33+
features {}
34+
subscription_id = var.subscription_id
35+
client_id = var.client_id
36+
client_secret = var.client_secret
37+
tenant_id = var.tenant_id
38+
}

workspace.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "azurerm_databricks_workspace" "this" {
2+
name = var.workspace_name != null ? var.workspace_name : "${var.teamid}-${var.prjid}"
3+
resource_group_name = azurerm_resource_group.this.name
4+
location = azurerm_resource_group.this.location
5+
sku = var.sku
6+
managed_resource_group_name = "${local.prefix}-workspace-rg"
7+
tags = local.tags
8+
}

0 commit comments

Comments
 (0)