Skip to content

Commit 234ecb4

Browse files
authored
migrate examples (#15)
1 parent d31f817 commit 234ecb4

File tree

155 files changed

+7352
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+7352
-0
lines changed

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
.terraform
22
*~
3+
4+
# Compiled files
5+
*.tfstate
6+
*.tfstate.backup
7+
*.tfstate.lock.info
8+
9+
# logs
10+
*.log
11+
12+
# Directories
13+
.terraform/
14+
.vagrant/
15+
16+
# SSH Keys
17+
*.pem
18+
19+
# Backup files
20+
*.bak
21+
22+
# Ignored Terraform files
23+
*gitignore*.tf
24+
25+
# Ignore Mac .DS_Store files
326
.DS_Store
27+
28+
# Ignored vscode files
29+
.vscode/

examples/adb-basic-demo/.terraform.lock.hcl

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/adb-basic-demo/main.tf

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Azure Provider source and version being used
2+
terraform {
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = ">=3.0.0"
7+
}
8+
databricks = {
9+
source = "databricks/databricks"
10+
version = ">=0.5.1"
11+
}
12+
}
13+
}
14+
15+
resource "random_string" "naming" {
16+
special = false
17+
upper = false
18+
length = 6
19+
}
20+
21+
resource "azurerm_resource_group" "example" {
22+
name = "${random_string.naming.result}-basic-demo-rg"
23+
location = var.rglocation
24+
}
25+
26+
locals {
27+
// dltp - databricks labs terraform provider
28+
prefix = join("-", [var.workspace_prefix, "${random_string.naming.result}"])
29+
location = var.rglocation
30+
dbfsname = join("", [var.dbfs_prefix, "${random_string.naming.result}"]) // dbfs name must not have special chars
31+
32+
// tags that are propagated down to all resources
33+
tags = {
34+
Environment = "Testing"
35+
Epoch = random_string.naming.result
36+
}
37+
}
38+
39+
40+
data "databricks_spark_version" "latest_lts" {
41+
long_term_support = true
42+
}
43+
44+
45+
module "auto_scaling_cluster_example" {
46+
source = "./modules/autoscaling_cluster"
47+
spark_version = data.databricks_spark_version.latest_lts.id
48+
node_type_id = var.node_type
49+
autotermination_minutes = var.global_auto_termination_minute
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Brief example of tf modules
2+
3+
A mini example to show modules in tf.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = ">=3.0.0"
6+
}
7+
databricks = {
8+
source = "databricks/databricks"
9+
version = ">=0.5.1"
10+
}
11+
}
12+
}
13+
14+
resource "databricks_cluster" "shared_autoscaling" {
15+
cluster_name = "Shared Autoscaling"
16+
spark_version = var.spark_version
17+
node_type_id = var.node_type_id
18+
autotermination_minutes = var.autotermination_minutes
19+
autoscale {
20+
min_workers = 1
21+
max_workers = 3
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "cluster_id" {
2+
value = databricks_cluster.shared_autoscaling.id
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variable "spark_version" {
2+
type = string
3+
}
4+
5+
variable "node_type_id" {
6+
type = string
7+
}
8+
9+
variable "autotermination_minutes" {
10+
type = number
11+
default = 60
12+
}

examples/adb-basic-demo/outputs.tf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "databricks_azure_workspace_resource_id" {
2+
// The ID of the Databricks Workspace in the Azure management plane.
3+
value = azurerm_databricks_workspace.example.id
4+
}
5+
6+
output "workspace_url" {
7+
// The workspace URL which is of the format 'adb-{workspaceId}.{random}.azuredatabricks.net'
8+
// this is not named as DATABRICKS_HOST, because it affect authentication
9+
value = "https://${azurerm_databricks_workspace.example.workspace_url}/"
10+
}
11+
12+
output "module_cluster_id" {
13+
// reference to module's outputs: value = module.module_name.output_attr_name
14+
value = module.auto_scaling_cluster_example.cluster_id
15+
}

examples/adb-basic-demo/providers.tf

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Configure the Microsoft Azure Provider
2+
provider "azurerm" {
3+
features {}
4+
}
5+
6+
provider "random" {
7+
}
8+
9+
provider "databricks" {
10+
host = azurerm_databricks_workspace.example.workspace_url
11+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dbfs_prefix="anotherdbfsname"

examples/adb-basic-demo/variables.tf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
variable "no_public_ip" {
2+
type = bool
3+
default = true
4+
}
5+
6+
variable "rglocation" {
7+
type = string
8+
default = "southeastasia"
9+
}
10+
11+
variable "dbfs_prefix" {
12+
type = string
13+
default = "dbfs"
14+
}
15+
16+
variable "node_type" {
17+
type = string
18+
default = "Standard_E8ds_v4"
19+
}
20+
21+
variable "workspace_prefix" {
22+
type = string
23+
default = "adb"
24+
}
25+
26+
variable "global_auto_termination_minute" {
27+
type = number
28+
default = 30
29+
}

examples/adb-basic-demo/workspace.tf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "azurerm_databricks_workspace" "example" {
2+
name = "${local.prefix}-workspace"
3+
resource_group_name = azurerm_resource_group.example.name
4+
location = azurerm_resource_group.example.location
5+
sku = "premium"
6+
tags = local.tags
7+
custom_parameters {
8+
no_public_ip = var.no_public_ip
9+
storage_account_name = local.dbfsname
10+
storage_account_sku_name = "Standard_LRS"
11+
}
12+
}

examples/adb-exfiltration-protection/.terraform.lock.hcl

+98
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)