Skip to content
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
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ repos:
rev: v1.48.0
hooks:
- id: terraform_fmt
# - id: terraform_validate
- id: terraform_tflint
args:
- '--args=--only=terraform_deprecated_interpolation'
- '--args=--only=terraform_deprecated_index'
# - '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_comment_syntax'
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_providers'
# - '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -28,9 +25,8 @@ repos:
- id: check-yaml

- repo: https://github.com/bridgecrewio/checkov.git
rev: '1.0.864' # change to tag or sha
rev: '2.0.531'
hooks:
- id: checkov
verbose: true
args:
- -d . --framework terraform -o output_format json
args: [-d, '.', --framework, 'terraform']
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# CHANGELOG

## [v0.0.9](https://github.com/tomarv2/terraform-databricks-aws-workspace/releases/tag/v0.0.9) - 2022-01-28 19:25:12

*No description*

### Bug Fixes

- general:
- fixing broken link in readme ([70da157](https://github.com/tomarv2/terraform-databricks-aws-workspace/commit/70da15703f048f4b880be1d415eb22db2047d7ee)) ([#4](https://github.com/tomarv2/terraform-databricks-aws-workspace/pull/4))

\* *This CHANGELOG was automatically generated by [auto-generate-changelog](https://github.com/BobAnkh/auto-generate-changelog)*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
>
> :point_right: Databricks account password: `databricks_account_password`
>
> :point_right: Databricks account id, `databricks_account_id` can be found on the top right corner of the page, once you're logged in.
> :point_right: Databricks account id, `databricks_account_id` can be found on the bottom left corner of the page, once you're logged in.
>
> :point_right: Part 2: Terraform module for [Databricks Workspace management](https://github.com/tomarv2/terraform-databricks-workspace-management)

Expand All @@ -36,7 +36,7 @@
## Versions

- Module tested for Terraform 1.0.1.
- `databrickslabs/databricks` provider version [0.3.5](https://registry.terraform.io/providers/databrickslabs/databricks/latest)
- `databrickslabs/databricks` provider version [0.4.7](https://registry.terraform.io/providers/databrickslabs/databricks/latest)
- AWS provider version [3.47](https://registry.terraform.io/providers/hashicorp/aws/latest).
- `main` branch: Provider versions not pinned to keep up with Terraform releases.
- `tags` releases: Tags are pinned with versions (use <a href="https://github.com/tomarv2/terraform-databricks-aws-workspace/tags" alt="GitHub tag">
Expand Down
6 changes: 3 additions & 3 deletions examples/sample/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module "databricks_workspace" {
# NOTE: One of the below is required:
# - 'profile_for_iam' - for IAM creation (if none is provided 'default' is used)
# - 'existing_role_name'
profile_for_iam = "iam-admin"
existing_role_name = "arn:aws:iam::123456789012:role/demo-role"
aws_region = "us-east-2"
profile_for_iam = "iam-admin"
#existing_role_name = "arn:aws:iam::123456789012:role/demo-role"
aws_region = "us-east-1"
databricks_account_username = "example@example.com"
databricks_account_password = "sample123!"
databricks_account_id = "1234567-1234-1234-1234-1234567"
Expand Down
9 changes: 2 additions & 7 deletions examples/sample/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ output "databricks_deployment_name" {
/*
output "pat_token" {
description = "databricks pat"
value = module.databricks_workspace.pat_token
}


output "pat_token_duration" {
description = "databricks pat"
value = module.databricks_workspace.pat_token_duration
value = module.databricks_workspace.databricks_token
sensitive = true
}
*/
7 changes: 3 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module "vpc" {
source = "git::git@github.com:tomarv2/terraform-aws-vpc.git?ref=v0.0.4"

aws_region = var.aws_region
enable_dns_hostnames = true
enable_nat_gateway = true
single_nat_gateway = true
Expand All @@ -25,12 +26,11 @@ module "vpc" {
}

module "iam_role" {
source = "git::git@github.com:tomarv2/terraform-aws-iam-role.git//modules/iam_role_external?ref=v0.0.4"
source = "git::git@github.com:tomarv2/terraform-aws-iam-role.git//modules/iam_role_external?ref=v0.0.7"

count = var.existing_role_name == null ? 1 : 0

assume_role_policy = data.databricks_aws_assume_role_policy.this.json
external_id = var.databricks_account_id
# -----------------------------------------
# Do not change the teamid, prjid once set.
teamid = var.teamid
Expand Down Expand Up @@ -60,9 +60,8 @@ module "iam_policies" {
}

module "s3" {
source = "git::git@github.com:tomarv2/terraform-aws-s3.git?ref=v0.0.3"
source = "git::git@github.com:tomarv2/terraform-aws-s3.git?ref=v0.0.6"

aws_region = var.aws_region
# -----------------------------------------
# Do not change the teamid, prjid once set.
teamid = var.teamid
Expand Down
11 changes: 7 additions & 4 deletions mws.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resource "databricks_mws_networks" "this" {
provider = databricks.mws
provider = databricks.mws

account_id = var.databricks_account_id
network_name = "${var.teamid}-${var.prjid}-${local.suffix}"
security_group_ids = [module.vpc.default_security_group_id]
Expand All @@ -8,7 +9,8 @@ resource "databricks_mws_networks" "this" {
}

resource "databricks_mws_credentials" "this" {
provider = databricks.mws
provider = databricks.mws

account_id = var.databricks_account_id
role_arn = var.existing_role_name != null ? var.existing_role_name : join("", module.iam_role.*.iam_role_arn)
credentials_name = "${var.teamid}-${var.prjid}-${local.suffix}"
Expand All @@ -17,8 +19,9 @@ resource "databricks_mws_credentials" "this" {
}

resource "databricks_mws_storage_configurations" "this" {
provider = databricks.mws
provider = databricks.mws

account_id = var.databricks_account_id
bucket_name = module.s3.s3_bucket_name
bucket_name = module.s3.bucket_name
storage_configuration_name = "${var.teamid}-${var.prjid}-${local.suffix}"
}
12 changes: 3 additions & 9 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ output "inline_policy_id" {

output "s3_bucket_name" {
description = "s3 bucket name"
value = module.s3.s3_bucket_name
value = module.s3.bucket_name
}

output "s3_bucket_arn" {
description = "s3 bucket arn"
value = module.s3.s3_bucket_arn
value = module.s3.bucket_arn
}

output "s3_bucket_id" {
description = "s3 bucket id"
value = module.s3.s3_bucket_id
value = module.s3.bucket_id
}

output "databricks_mws_credentials_id" {
Expand Down Expand Up @@ -93,10 +93,4 @@ output "databricks_token" {
value = databricks_token.pat.id
sensitive = true
}


output "pat_token_duration" {
description = "databricks pat"
value = databricks_token.pat.lifetime_seconds
}
*/
2 changes: 1 addition & 1 deletion pat_token.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
/*
resource "databricks_token" "pat" {
provider = databricks.created_workspace
provider = databricks.created_workspace

comment = "Terraform managed: ${var.teamid}-${var.prjid}"
lifetime_seconds = 86400
Expand Down
4 changes: 2 additions & 2 deletions s3.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
data "databricks_aws_bucket_policy" "this" {
bucket = module.s3.s3_bucket_name
bucket = module.s3.bucket_name
}

resource "aws_s3_bucket_policy" "root_bucket_policy" {
bucket = module.s3.s3_bucket_id
bucket = module.s3.bucket_id
policy = data.databricks_aws_bucket_policy.this.json
depends_on = [databricks_mws_networks.this]
}
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ variable "aws_region" {
default = "us-west-2"
}

variable "databricks_hostname" {
description = "databricks hostname"
type = string
default = "https://accounts.cloud.databricks.com"
}

variable "databricks_account_username" {
description = "databricks account username"
type = string
}

variable "databricks_account_password" {
description = "databricks account password"
type = string
Expand Down
11 changes: 7 additions & 4 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
databricks = {
source = "databrickslabs/databricks"
version = "0.3.5"
version = "0.4.7"
}
random = {
version = "~> 3.1"
Expand All @@ -17,6 +17,7 @@ terraform {
}
}


provider "aws" {
region = var.aws_region
profile = var.profile_to_use
Expand All @@ -30,15 +31,17 @@ provider "aws" {
}

provider "aws" {
alias = "iam-management"
alias = "iam-management"

region = var.aws_region
profile = local.profile_to_use
}

# initialize provider in "MWS" mode to provision new workspace
provider "databricks" {
alias = "mws"
host = "https://accounts.cloud.databricks.com"
alias = "mws"

host = var.databricks_hostname
username = var.databricks_account_username
password = var.databricks_account_password
}
Expand Down
3 changes: 2 additions & 1 deletion workspaces.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resource "databricks_mws_workspaces" "this" {
provider = databricks.mws
provider = databricks.mws

account_id = var.databricks_account_id
aws_region = var.aws_region
workspace_name = "${var.teamid}-${var.prjid}"
Expand Down