From 300949a0299a543d803e869f7cc313d13c9df9b7 Mon Sep 17 00:00:00 2001 From: ryan-gord-db <60911136+ryan-gord-db@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:34:17 -0400 Subject: [PATCH] [Doc] Updates to resource examples (#4093) ## Changes Updated a few code examples to reflect syntax for the current provider version and to address referential integrity issues ## Tests - [ ] `make test` run locally - [x] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] relevant acceptance tests are passing - [ ] using Go SDK --- docs/data-sources/aws_bucket_policy.md | 6 ++---- docs/data-sources/aws_unity_catalog_policy.md | 2 +- docs/data-sources/cluster.md | 2 +- docs/data-sources/instance_pool.md | 2 +- docs/data-sources/metastore.md | 4 ++++ docs/data-sources/sql_warehouse.md | 4 ++-- docs/data-sources/views.md | 2 +- docs/data-sources/volume.md | 4 ++-- docs/resources/cluster_policy.md | 2 +- docs/resources/lakehouse_monitor.md | 1 - docs/resources/mws_credentials.md | 10 +++++++--- docs/resources/mws_customer_managed_keys.md | 2 ++ docs/resources/permissions.md | 2 ++ docs/resources/quality_monitor.md | 1 - 14 files changed, 26 insertions(+), 18 deletions(-) diff --git a/docs/data-sources/aws_bucket_policy.md b/docs/data-sources/aws_bucket_policy.md index d3e6bded1c..e42949e06a 100644 --- a/docs/data-sources/aws_bucket_policy.md +++ b/docs/data-sources/aws_bucket_policy.md @@ -10,12 +10,11 @@ This datasource configures a simple access policy for AWS S3 buckets, so that Da ```hcl resource "aws_s3_bucket" "this" { bucket = "" - acl = "private" force_destroy = true } -data "databricks_aws_bucket_policy" "stuff" { - bucket_name = aws_s3_bucket.this.bucket +data "databricks_aws_bucket_policy" "this" { + bucket = aws_s3_bucket.this.bucket } resource "aws_s3_bucket_policy" "this" { @@ -29,7 +28,6 @@ Bucket policy with full access: ```hcl resource "aws_s3_bucket" "ds" { bucket = "${var.prefix}-ds" - acl = "private" force_destroy = true tags = merge(var.tags, { Name = "${var.prefix}-ds" diff --git a/docs/data-sources/aws_unity_catalog_policy.md b/docs/data-sources/aws_unity_catalog_policy.md index 6a929b70d2..3804b1d5fa 100644 --- a/docs/data-sources/aws_unity_catalog_policy.md +++ b/docs/data-sources/aws_unity_catalog_policy.md @@ -30,7 +30,7 @@ resource "aws_iam_policy" "unity_metastore" { resource "aws_iam_role" "metastore_data_access" { name = "${var.prefix}-uc-access" - assume_role_policy = data.aws_iam_policy_document.this.json + assume_role_policy = data.databricks_aws_unity_catalog_assume_role_policy.this.json managed_policy_arns = [aws_iam_policy.unity_metastore.arn] } ``` diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 7e5cdbba2b..73146d05ac 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -16,7 +16,7 @@ data "databricks_clusters" "all" { } data "databricks_cluster" "all" { - for_each = data.databricks_clusters.ids + for_each = data.databricks_clusters.all.ids cluster_id = each.value } diff --git a/docs/data-sources/instance_pool.md b/docs/data-sources/instance_pool.md index 052e4dea28..72f0a6f50a 100644 --- a/docs/data-sources/instance_pool.md +++ b/docs/data-sources/instance_pool.md @@ -13,7 +13,7 @@ Retrieves information about [databricks_instance_pool](../resources/instance_poo Referring to an instance pool by name: ```hcl -data "databricks_instance_pool" "Pool" { +data "databricks_instance_pool" "pool" { name = "All spot" } diff --git a/docs/data-sources/metastore.md b/docs/data-sources/metastore.md index db59fc7488..33a6060f15 100644 --- a/docs/data-sources/metastore.md +++ b/docs/data-sources/metastore.md @@ -14,6 +14,10 @@ Retrieves information about metastore for a given id of [databricks_metastore](. MetastoreInfo response for a given metastore id ```hcl +resource "aws_s3_bucket" "metastore" { + bucket = "${var.prefix}-metastore" + force_destroy = true +} resource "databricks_metastore" "this" { provider = databricks.workspace diff --git a/docs/data-sources/sql_warehouse.md b/docs/data-sources/sql_warehouse.md index b930545f89..28080d6518 100644 --- a/docs/data-sources/sql_warehouse.md +++ b/docs/data-sources/sql_warehouse.md @@ -15,8 +15,8 @@ Retrieves information about a [databricks_sql_warehouse](../resources/sql_endpoi data "databricks_sql_warehouses" "all" { } -data "databricks_sql_warehouse" "all" { - for_each = data.databricks_sql.warehouses.ids +data "databricks_sql_warehouse" "this" { + for_each = data.databricks_sql_warehouses.all.ids id = each.value } ``` diff --git a/docs/data-sources/views.md b/docs/data-sources/views.md index df076fbc4d..d36315438a 100644 --- a/docs/data-sources/views.md +++ b/docs/data-sources/views.md @@ -20,7 +20,7 @@ data "databricks_views" "things" { resource "databricks_grants" "things" { for_each = data.databricks_views.things.ids - view = each.value + table = each.value grant { principal = "sensitive" diff --git a/docs/data-sources/volume.md b/docs/data-sources/volume.md index 3a6ebeba3f..5a4bcc0e4d 100644 --- a/docs/data-sources/volume.md +++ b/docs/data-sources/volume.md @@ -16,8 +16,8 @@ data "databricks_volumes" "all" { schema_name = "things" } -data "databricks_volume" { - for_each = data.datatbricks_volumes.all.ids +data "databricks_volume" "this" { + for_each = data.databricks_volumes.all.ids name = each.value } ``` diff --git a/docs/resources/cluster_policy.md b/docs/resources/cluster_policy.md index 186c04cd7f..df94d849b6 100644 --- a/docs/resources/cluster_policy.md +++ b/docs/resources/cluster_policy.md @@ -132,7 +132,7 @@ locals { resource "databricks_cluster_policy" "personal_vm" { policy_family_id = "personal-vm" - policy_family_definition_overrides = jsonencode(personal_vm_override) + policy_family_definition_overrides = jsonencode(local.personal_vm_override) name = "Personal Compute" } ``` diff --git a/docs/resources/lakehouse_monitor.md b/docs/resources/lakehouse_monitor.md index d526f6fbc1..635399dcc9 100644 --- a/docs/resources/lakehouse_monitor.md +++ b/docs/resources/lakehouse_monitor.md @@ -38,7 +38,6 @@ resource "databricks_sql_table" "myTestTable" { column { name = "timestamp" - position = 1 type = "int" } } diff --git a/docs/resources/mws_credentials.md b/docs/resources/mws_credentials.md index 0a5c69daae..1676d89d6b 100644 --- a/docs/resources/mws_credentials.md +++ b/docs/resources/mws_credentials.md @@ -16,12 +16,16 @@ variable "databricks_account_id" { description = "Account Id that could be found in the top right corner of https://accounts.cloud.databricks.com/" } +variable "prefix" { + description = "Names of created resources will be prefixed with this value" +} + data "databricks_aws_assume_role_policy" "this" { external_id = var.databricks_account_id } resource "aws_iam_role" "cross_account_role" { - name = "${local.prefix}-crossaccount" + name = "${var.prefix}-crossaccount" assume_role_policy = data.databricks_aws_assume_role_policy.this.json tags = var.tags } @@ -30,14 +34,14 @@ data "databricks_aws_crossaccount_policy" "this" { } resource "aws_iam_role_policy" "this" { - name = "${local.prefix}-policy" + name = "${var.prefix}-policy" role = aws_iam_role.cross_account_role.id policy = data.databricks_aws_crossaccount_policy.this.json } resource "databricks_mws_credentials" "this" { provider = databricks.mws - credentials_name = "${local.prefix}-creds" + credentials_name = "${var.prefix}-creds" role_arn = aws_iam_role.cross_account_role.arn } ``` diff --git a/docs/resources/mws_customer_managed_keys.md b/docs/resources/mws_customer_managed_keys.md index 206158766d..cc48954402 100644 --- a/docs/resources/mws_customer_managed_keys.md +++ b/docs/resources/mws_customer_managed_keys.md @@ -110,6 +110,8 @@ variable "databricks_cross_account_role" { description = "AWS ARN for the Databricks cross account role" } +data "aws_caller_identity" "current" {} + data "aws_iam_policy_document" "databricks_storage_cmk" { version = "2012-10-17" statement { diff --git a/docs/resources/permissions.md b/docs/resources/permissions.md index 8e2e236dfe..868e2aa835 100644 --- a/docs/resources/permissions.md +++ b/docs/resources/permissions.md @@ -232,6 +232,8 @@ There are four assignable [permission levels](https://docs.databricks.com/securi - Read [main documentation](https://docs.databricks.com/security/access-control/dlt-acl.html) for additional detail. ```hcl +data "databricks_current_user" "me" {} + resource "databricks_group" "eng" { display_name = "Engineering" } diff --git a/docs/resources/quality_monitor.md b/docs/resources/quality_monitor.md index b01208c80e..71613a6e0d 100644 --- a/docs/resources/quality_monitor.md +++ b/docs/resources/quality_monitor.md @@ -36,7 +36,6 @@ resource "databricks_sql_table" "myTestTable" { column { name = "timestamp" - position = 1 type = "int" } }