Skip to content

Commit

Permalink
[Doc] Updates to resource examples (#4093)
Browse files Browse the repository at this point in the history
## Changes
Updated a few code examples to reflect syntax for the current provider
version and to address referential integrity issues

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant 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
  • Loading branch information
ryan-gord-db authored Oct 10, 2024
1 parent 2c5dc8a commit 300949a
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 18 deletions.
6 changes: 2 additions & 4 deletions docs/data-sources/aws_bucket_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<unique_bucket_name>"
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" {
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/aws_unity_catalog_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/instance_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/metastore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/sql_warehouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/cluster_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```
Expand Down
1 change: 0 additions & 1 deletion docs/resources/lakehouse_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ resource "databricks_sql_table" "myTestTable" {
column {
name = "timestamp"
position = 1
type = "int"
}
}
Expand Down
10 changes: 7 additions & 3 deletions docs/resources/mws_credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
```
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/mws_customer_managed_keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 0 additions & 1 deletion docs/resources/quality_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ resource "databricks_sql_table" "myTestTable" {
column {
name = "timestamp"
position = 1
type = "int"
}
}
Expand Down

0 comments on commit 300949a

Please sign in to comment.