Create a table from external location volume using terraform
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2025 08:27 AM
Hi everyone,
I’m trying to create a table in Unity Catalog from a folder that lives inside a Volume, but I can’t get Terraform to create it successfully.
Below is the simplified/anonymous version of my Terraform setup.
I have:
* A Unity Catalog
* A Schema
* A Storage Credential (AWS IAM role)
* An External Location
* A Volume mapped to that external location
* A folder inside the Volume (e.g., /Volumes/my_catalog/my_schema/my_volume/gold_layer/)
resource "databricks_catalog" "example_catalog" {
name = "my-catalog"
comment = "example"
}
resource "databricks_schema" "example_schema" {
catalog_name = databricks_catalog.example_catalog.id
name = "my-schema"
}
resource "databricks_storage_credential" "example_cred" {
name = "example-cred"
aws_iam_role {
role_arn = var.example_role_arn
}
}
resource "databricks_external_location" "example_location" {
name = "example-location"
url = var.example_s3_path # e.g. s3://my-bucket/path/
credential_name = databricks_storage_credential.example_cred.id
read_only = true
skip_validation = true
}
resource "databricks_volume" "example_volume" {
name = "my-volume"
catalog_name = databricks_catalog.example_catalog.name
schema_name = databricks_schema.example_schema.name
volume_type = "EXTERNAL"
storage_location = databricks_external_location.example_location.url
}* I want to use that folder and create a table. Using the Databricks UI i can do this and everything is fine, but with terrafom i can't figure how except creating a view like this:
resource "databricks_sql_table" "example_view" {
name = "gold_layer"
catalog_name = databricks_catalog.example_catalog.name
schema_name = databricks_schema.example_schema.name
table_type = "VIEW"
view_definition = "SELECT * FROM read_files('/Volumes/${databricks_catalog.example_catalog.name}/${databricks_schema.example_schema.name}/${databricks_volume.example_volume.name}/gold_layer/')"
}