Skip to content

Improve aws-workspace-basic example #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions examples/aws-workspace-basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ This template provides an example of a simple deployment of AWS Databricks E2 wo
1. Reference this module using one of the different [module source types](https://developer.hashicorp.com/terraform/language/modules/sources)
2. Add a `variables.tf` with the same content in [variables.tf](variables.tf)
3. Add a `terraform.tfvars` file and provide values to each defined variable
4. Configure the following environment variables:
* TF_VAR_databricks_account_client_id, set to the value of application ID of your Databricks account-level service principal with admin permission.
* TF_VAR_databricks_account_client_secret, set to the value of the client secret for your Databricks account-level service principal.
* TF_VAR_databricks_account_id, set to the value of the ID of your Databricks account. You can find this value in the corner of your Databricks account console.
4. Configure authentication to the Databricks Account (i.e., via Databricks CLI profiles or service principal).
5. Add a `output.tf` file.
6. (Optional) Configure your [remote backend](https://developer.hashicorp.com/terraform/language/settings/backends/s3)
7. Run `terraform init` to initialize terraform and get provider ready.
Expand Down Expand Up @@ -51,7 +48,8 @@ No resources.
| <a name="input_databricks_account_id"></a> [databricks\_account\_id](#input\_databricks\_account\_id) | Databricks Account ID | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS region to deploy to | `string` | `"eu-west-1"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Optional tags to add to created resources | `map(string)` | `{}` | no |
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Optional prefix to add to resource names | `string` | `""` | no |

## Outputs

No outputs.
No outputs.
6 changes: 5 additions & 1 deletion examples/aws-workspace-basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module "aws-workspace-basic" {
source = "github.com/databricks/terraform-databricks-examples/modules/aws-workspace-basic"
databricks_account_id = var.databricks_account_id
}
region = var.region
tags = var.tags
prefix = var.prefix
cidr_block = var.cidr_block
}
6 changes: 6 additions & 0 deletions examples/aws-workspace-basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ variable "region" {
type = string
description = "AWS region to deploy to"
}

variable "prefix" {
default = ""
type = string
description = "Prefix for use in the generated names"
}
3 changes: 2 additions & 1 deletion examples/aws-workspace-basic/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ provider "aws" {

provider "databricks" {
host = "https://accounts.cloud.databricks.com"
}
account_id = var.databricks_account_id
}
2 changes: 1 addition & 1 deletion modules/aws-workspace-basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ variable "region" {
}

variable "prefix" {
default = "demo"
default = ""
type = string
description = "Prefix for use in the generated names"
}
3 changes: 1 addition & 2 deletions modules/aws-workspace-basic/workspace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ resource "databricks_mws_storage_configurations" "this" {
}

resource "databricks_mws_credentials" "this" {
account_id = var.databricks_account_id
role_arn = aws_iam_role.cross_account_role.arn
credentials_name = "${local.prefix}-creds"
depends_on = [time_sleep.wait]
Expand All @@ -39,4 +38,4 @@ resource "databricks_mws_workspaces" "this" {
token {
comment = "Terraform"
}
}
}