Skip to content

Commit 8e4f90b

Browse files
author
Artem Vovchenko
committed
fix: make defining permissions optional
1 parent 9122613 commit 8e4f90b

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ module "databricks_locations" {
7474

7575
| Name | Version |
7676
|------|---------|
77-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >=1.0.0 |
78-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 4.0.1 |
77+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~>1.3 |
7978
| <a name="requirement_databricks"></a> [databricks](#requirement\_databricks) | ~>1.0 |
8079

8180
## Providers
@@ -101,8 +100,9 @@ No modules.
101100

102101
| Name | Description | Type | Default | Required |
103102
|------|-------------|------|---------|:--------:|
104-
| <a name="input_external_locations"></a> [external\_locations](#input\_external\_locations) | List of object with external location configuration attributes | <pre>list(object({<br/> index = string # Index of instance, for example short name, used later to access exact external location in output map<br/> name = string # Custom whole name of resource<br/> url = string # Path URL in cloud storage<br/> credentials_name = optional(string)<br/> owner = optional(string) # Owner of resource<br/> skip_validation = optional(bool, true) # Suppress validation errors if any & force save the external location<br/> read_only = optional(bool, false) # Indicates whether the external location is read-only.<br/> force_destroy = optional(bool, true)<br/> force_update = optional(bool, true)<br/> comment = optional(string, "External location provisioned by Terraform")<br/> permissions = optional(set(object({<br/> principal = string<br/> privileges = list(string)<br/> })), [])<br/> isolation_mode = optional(string, "ISOLATION_MODE_OPEN")<br/> }))</pre> | `[]` | no |
105-
| <a name="input_storage_credential"></a> [storage\_credential](#input\_storage\_credential) | Object with storage credentials configuration attributes | <pre>object({<br/> azure_access_connector_id = optional(string, null) # Azure Databricks Access Connector Id<br/> cloud = optional(string, "")<br/> name = optional(string, null) # Custom whole name of resource <br/> owner = optional(string) # Owner of resource<br/> force_destroy = optional(bool, true)<br/> comment = optional(string, "Managed identity credential provisioned by Terraform")<br/> permissions = optional(set(object({<br/> principal = string<br/> privileges = list(string)<br/> })), [])<br/> isolation_mode = optional(string, "ISOLATION_MODE_OPEN")<br/> })</pre> | n/a | yes |
103+
| <a name="input_cloud"></a> [cloud](#input\_cloud) | Cloud (azure, aws or gcp) | `string` | n/a | yes |
104+
| <a name="input_external_locations"></a> [external\_locations](#input\_external\_locations) | List of object with external location configuration attributes | <pre>list(object({<br/> index = string # Index of instance, for example short name, used later to access exact external location in output map<br/> name = string # Custom whole name of resource<br/> url = string # Path URL in cloud storage<br/> credentials_name = optional(string) # If storage_credential.create_storage_credential is set to false, provide id of existing storage credential here<br/> owner = optional(string) # Owner of resource<br/> skip_validation = optional(bool, true) # Suppress validation errors if any & force save the external location<br/> read_only = optional(bool, false) # Indicates whether the external location is read-only.<br/> force_destroy = optional(bool, true)<br/> force_update = optional(bool, true)<br/> comment = optional(string, "External location provisioned by Terraform")<br/> permissions = optional(set(object({<br/> principal = string<br/> privileges = list(string)<br/> })), [])<br/> isolation_mode = optional(string, "ISOLATION_MODE_OPEN")<br/> }))</pre> | `[]` | no |
105+
| <a name="input_storage_credential"></a> [storage\_credential](#input\_storage\_credential) | Object with storage credentials configuration attributes | <pre>object({<br/> azure_access_connector_id = optional(string, null) # Azure Databricks Access Connector Id<br/> name = optional(string, null) # Custom whole name of resource<br/> owner = optional(string) # Owner of resource<br/> force_destroy = optional(bool, true)<br/> comment = optional(string, "Managed identity credential provisioned by Terraform")<br/> create_storage_credential = optional(bool, true) # "Boolean flag that determines whether to create storage credential or use the existing one"<br/> permissions = optional(set(object({<br/> principal = string<br/> privileges = list(string)<br/> })), [])<br/> isolation_mode = optional(string, "ISOLATION_MODE_OPEN")<br/> })</pre> | n/a | yes |
106106

107107
## Outputs
108108

main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,32 @@ locals {
1313
}
1414

1515
resource "databricks_storage_credential" "this" {
16-
count = var.storage_credential.cloud != "" ? 1 : 0
16+
count = var.storage_credential.create_storage_credential ? 1 : 0
1717

1818
name = var.storage_credential.name
1919
owner = var.storage_credential.owner
2020

2121
# Dynamic block for Azure
2222
dynamic "azure_managed_identity" {
23-
for_each = var.storage_credential.cloud == "azure" ? [1] : []
23+
for_each = var.cloud == "azure" ? [1] : []
2424
content {
2525
access_connector_id = var.storage_credential.azure_access_connector_id
2626
}
2727
}
2828

2929
# Dynamic block for GCP
3030
dynamic "databricks_gcp_service_account" {
31-
for_each = var.storage_credential.cloud == "gcp" ? [1] : []
31+
for_each = var.cloud == "gcp" ? [1] : []
3232
content {}
3333
}
3434

3535
force_destroy = var.storage_credential.force_destroy
3636
comment = var.storage_credential.comment
37-
isolation_mode = var.storage_credential.cloud == "azure" ? var.storage_credential.isolation_mode : null
37+
isolation_mode = var.cloud == "azure" ? var.storage_credential.isolation_mode : null
3838
}
3939

4040
resource "databricks_grants" "credential" {
41-
count = var.storage_credential.cloud != "" ? 1 : 0
41+
count = var.storage_credential.create_storage_credential ? (length(var.storage_credential.permissions) != 0 ? 1 : 0) : 0
4242

4343
storage_credential = try(databricks_storage_credential.this[0].id, null)
4444
dynamic "grant" {

variables.tf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
variable "storage_credential" {
22
type = object({
33
azure_access_connector_id = optional(string, null) # Azure Databricks Access Connector Id
4-
cloud = optional(string, "")
5-
name = optional(string, null) # Custom whole name of resource
4+
name = optional(string, null) # Custom whole name of resource
65
owner = optional(string) # Owner of resource
76
force_destroy = optional(bool, true)
87
comment = optional(string, "Managed identity credential provisioned by Terraform")
8+
create_storage_credential = optional(bool, true) # "Boolean flag that determines whether to create storage credential or use the existing one"
99
permissions = optional(set(object({
1010
principal = string
1111
privileges = list(string)
@@ -15,12 +15,17 @@ variable "storage_credential" {
1515
description = "Object with storage credentials configuration attributes"
1616
}
1717

18+
variable "cloud" {
19+
type = string
20+
description = "Cloud (azure, aws or gcp)"
21+
}
22+
1823
variable "external_locations" {
1924
type = list(object({
20-
index = string # Index of instance, for example short name, used later to access exact external location in output map
21-
name = string # Custom whole name of resource
22-
url = string # Path URL in cloud storage
23-
credentials_name = optional(string)
25+
index = string # Index of instance, for example short name, used later to access exact external location in output map
26+
name = string # Custom whole name of resource
27+
url = string # Path URL in cloud storage
28+
credentials_name = optional(string) # If storage_credential.create_storage_credential is set to false, provide id of existing storage credential here
2429
owner = optional(string) # Owner of resource
2530
skip_validation = optional(bool, true) # Suppress validation errors if any & force save the external location
2631
read_only = optional(bool, false) # Indicates whether the external location is read-only.

versions.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
terraform {
2-
required_version = ">=1.0.0"
2+
required_version = "~>1.3"
33

44
required_providers {
5-
azurerm = {
6-
source = "hashicorp/azurerm"
7-
version = ">= 4.0.1"
8-
}
95
databricks = {
106
source = "databricks/databricks"
117
version = "~>1.0"

0 commit comments

Comments
 (0)