Skip to content

Commit 320c000

Browse files
committed
cleanup
1 parent 228484b commit 320c000

File tree

11 files changed

+118
-129
lines changed

11 files changed

+118
-129
lines changed

README.md

+26-20
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module "databricks_workspace" {
116116
# - 'profile_for_iam' - for IAM creation (if none is provided 'default' is used)
117117
# - 'existing_role_name'
118118
profile_for_iam = "iam-admin"
119-
aws_region = "us-east-2"
119+
120120
databricks_account_username = "[email protected]"
121121
databricks_account_password = "sample123!"
122122
databricks_account_id = "1234567-1234-1234-1234-1234567"
@@ -136,7 +136,7 @@ module "databricks_workspace" {
136136
# - 'profile_for_iam' - for IAM creation (if none is provided 'default' is used)
137137
# - 'existing_role_name'
138138
existing_role_arn = "arn:aws:iam::123456789012:role/demo-role"
139-
aws_region = "us-east-2"
139+
140140
databricks_account_username = "[email protected]"
141141
databricks_account_password = "sample123!"
142142
databricks_account_id = "1234567-1234-1234-1234-1234567"
@@ -176,50 +176,52 @@ Error: MALFORMED_REQUEST: Failed credentials validation checks: Spot Cancellatio
176176
| Name | Version |
177177
|------|---------|
178178
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.1 |
179-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 3.47 |
180-
| <a name="requirement_databricks"></a> [databricks](#requirement\_databricks) | 0.4.7 |
179+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 3.63 |
180+
| <a name="requirement_databricks"></a> [databricks](#requirement\_databricks) | 0.5.1 |
181181
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.1 |
182182
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.7 |
183183

184184
## Providers
185185

186186
| Name | Version |
187187
|------|---------|
188-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 3.47 |
189-
| <a name="provider_databricks"></a> [databricks](#provider\_databricks) | 0.4.7 |
190-
| <a name="provider_databricks.mws"></a> [databricks.mws](#provider\_databricks.mws) | 0.4.7 |
191-
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.1 |
192-
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.7 |
188+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.3 |
189+
| <a name="provider_databricks"></a> [databricks](#provider\_databricks) | 0.5.1 |
190+
| <a name="provider_databricks.created_workspace"></a> [databricks.created\_workspace](#provider\_databricks.created\_workspace) | 0.5.1 |
191+
| <a name="provider_databricks.mws"></a> [databricks.mws](#provider\_databricks.mws) | 0.5.1 |
192+
| <a name="provider_random"></a> [random](#provider\_random) | 3.1.0 |
193+
| <a name="provider_time"></a> [time](#provider\_time) | 0.7.2 |
193194

194195
## Modules
195196

196197
| Name | Source | Version |
197198
|------|--------|---------|
198199
| <a name="module_iam_policies"></a> [iam\_policies](#module\_iam\_policies) | git::[email protected]:tomarv2/terraform-aws-iam-policies.git | v0.0.4 |
199200
| <a name="module_iam_role"></a> [iam\_role](#module\_iam\_role) | git::[email protected]:tomarv2/terraform-aws-iam-role.git//modules/iam_role_external | v0.0.7 |
200-
| <a name="module_s3"></a> [s3](#module\_s3) | git::[email protected]:tomarv2/terraform-aws-s3.git | v0.0.7 |
201-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | git::[email protected]:tomarv2/terraform-aws-vpc.git | v0.0.4 |
201+
| <a name="module_s3"></a> [s3](#module\_s3) | git::[email protected]:tomarv2/terraform-aws-s3.git | v0.0.8 |
202+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | git::[email protected]:tomarv2/terraform-aws-vpc.git | v0.0.6 |
202203

203204
## Resources
204205

205206
| Name | Type |
206207
|------|------|
207208
| [aws_s3_bucket_policy.root_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
208-
| [databricks_mws_credentials.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/resources/mws_credentials) | resource |
209-
| [databricks_mws_networks.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/resources/mws_networks) | resource |
210-
| [databricks_mws_storage_configurations.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/resources/mws_storage_configurations) | resource |
211-
| [databricks_mws_workspaces.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/resources/mws_workspaces) | resource |
209+
| [databricks_mws_credentials.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/resources/mws_credentials) | resource |
210+
| [databricks_mws_networks.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/resources/mws_networks) | resource |
211+
| [databricks_mws_storage_configurations.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/resources/mws_storage_configurations) | resource |
212+
| [databricks_mws_workspaces.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/resources/mws_workspaces) | resource |
213+
| [databricks_token.pat](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/resources/token) | resource |
212214
| [random_string.naming](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
213215
| [time_sleep.wait](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
214-
| [databricks_aws_assume_role_policy.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/data-sources/aws_assume_role_policy) | data source |
215-
| [databricks_aws_bucket_policy.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/data-sources/aws_bucket_policy) | data source |
216-
| [databricks_aws_crossaccount_policy.cross_account_iam_policy](https://registry.terraform.io/providers/databrickslabs/databricks/0.4.7/docs/data-sources/aws_crossaccount_policy) | data source |
216+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
217+
| [databricks_aws_assume_role_policy.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/data-sources/aws_assume_role_policy) | data source |
218+
| [databricks_aws_bucket_policy.this](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/data-sources/aws_bucket_policy) | data source |
219+
| [databricks_aws_crossaccount_policy.cross_account_iam_policy](https://registry.terraform.io/providers/databrickslabs/databricks/0.5.1/docs/data-sources/aws_crossaccount_policy) | data source |
217220

218221
## Inputs
219222

220223
| Name | Description | Type | Default | Required |
221224
|------|-------------|------|---------|:--------:|
222-
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | default aws region | `string` | `"us-west-2"` | no |
223225
| <a name="input_cidr_block"></a> [cidr\_block](#input\_cidr\_block) | The CIDR block for the VPC | `string` | `"10.4.0.0/16"` | no |
224226
| <a name="input_custom_tags"></a> [custom\_tags](#input\_custom\_tags) | Extra custom tags | `any` | `null` | no |
225227
| <a name="input_databricks_account_id"></a> [databricks\_account\_id](#input\_databricks\_account\_id) | External ID provided by third party. | `string` | n/a | yes |
@@ -228,8 +230,9 @@ Error: MALFORMED_REQUEST: Failed credentials validation checks: Spot Cancellatio
228230
| <a name="input_databricks_hostname"></a> [databricks\_hostname](#input\_databricks\_hostname) | databricks hostname | `string` | `"https://accounts.cloud.databricks.com"` | no |
229231
| <a name="input_existing_role_name"></a> [existing\_role\_name](#input\_existing\_role\_name) | If you want to use existing role name, else a new role will be created | `string` | `null` | no |
230232
| <a name="input_prjid"></a> [prjid](#input\_prjid) | Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply' | `string` | n/a | yes |
233+
| <a name="input_profile"></a> [profile](#input\_profile) | profile to use for resource creation | `string` | `"default"` | no |
231234
| <a name="input_profile_for_iam"></a> [profile\_for\_iam](#input\_profile\_for\_iam) | profile to use for IAM | `string` | `null` | no |
232-
| <a name="input_profile"></a> [profile\_to\_use](#input\_profile\_to\_use) | Getting values from ~/.aws/credentials | `string` | `"default"` | no |
235+
| <a name="input_region"></a> [region](#input\_region) | AWS region to deploy resources | `string` | `"us-east-1"` | no |
233236
| <a name="input_teamid"></a> [teamid](#input\_teamid) | Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply' | `string` | n/a | yes |
234237

235238
## Outputs
@@ -243,8 +246,11 @@ Error: MALFORMED_REQUEST: Failed credentials validation checks: Spot Cancellatio
243246
| <a name="output_databricks_mws_network_id"></a> [databricks\_mws\_network\_id](#output\_databricks\_mws\_network\_id) | databricks mws network id |
244247
| <a name="output_databricks_mws_storage_bucket_name"></a> [databricks\_mws\_storage\_bucket\_name](#output\_databricks\_mws\_storage\_bucket\_name) | databricks mws storage bucket name |
245248
| <a name="output_databricks_mws_storage_id"></a> [databricks\_mws\_storage\_id](#output\_databricks\_mws\_storage\_id) | databricks mws storage id |
249+
| <a name="output_databricks_token"></a> [databricks\_token](#output\_databricks\_token) | Value of the newly created token |
250+
| <a name="output_databricks_token_lifetime_hours"></a> [databricks\_token\_lifetime\_hours](#output\_databricks\_token\_lifetime\_hours) | Token validity |
246251
| <a name="output_iam_role_arn"></a> [iam\_role\_arn](#output\_iam\_role\_arn) | iam role arn |
247252
| <a name="output_inline_policy_id"></a> [inline\_policy\_id](#output\_inline\_policy\_id) | inline policy id |
253+
| <a name="output_nonsensitive_databricks_token"></a> [nonsensitive\_databricks\_token](#output\_nonsensitive\_databricks\_token) | Value of the newly created token (nonsensitive) |
248254
| <a name="output_s3_bucket_arn"></a> [s3\_bucket\_arn](#output\_s3\_bucket\_arn) | s3 bucket arn |
249255
| <a name="output_s3_bucket_id"></a> [s3\_bucket\_id](#output\_s3\_bucket\_id) | s3 bucket id |
250256
| <a name="output_s3_bucket_name"></a> [s3\_bucket\_name](#output\_s3\_bucket\_name) | s3 bucket name |

examples/sample/main.tf

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
terraform {
2-
required_version = ">= 1.0.1"
3-
required_providers {
4-
aws = {
5-
version = "~> 3.63"
6-
}
7-
}
8-
}
9-
10-
provider "aws" {
11-
region = var.aws_region
12-
}
13-
141
module "databricks_workspace" {
152
source = "../../"
163

@@ -19,11 +6,11 @@ module "databricks_workspace" {
196
# - 'existing_role_name'
207
profile_for_iam = "iam-admin"
218
#existing_role_name = "arn:aws:iam::123456789012:role/demo-role"
22-
aws_region = var.aws_region
9+
2310
databricks_account_username = "[email protected]"
2411
databricks_account_password = "sample123!"
2512
databricks_account_id = "1234567-1234-1234-1234-1234567"
26-
13+
region = var.region
2714
custom_tags = tomap(
2815
{
2916
"Dept" = "data",

examples/sample/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ variable "prjid" {
88
type = string
99
}
1010

11-
variable "aws_region" {
11+
variable "region" {
1212
description = "AWS region to deploy resources"
1313
type = string
1414
default = "us-west-2"

iam.tf

+35
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,38 @@ data "databricks_aws_assume_role_policy" "this" {
33
}
44

55
data "databricks_aws_crossaccount_policy" "cross_account_iam_policy" {}
6+
7+
8+
module "iam_role" {
9+
source = "git::[email protected]:tomarv2/terraform-aws-iam-role.git//modules/iam_role_external?ref=v0.0.7"
10+
11+
count = var.existing_role_name == null ? 1 : 0
12+
13+
assume_role_policy = data.databricks_aws_assume_role_policy.this.json
14+
# -----------------------------------------
15+
# Do not change the teamid, prjid once set.
16+
teamid = var.teamid
17+
prjid = "${var.prjid}-${local.suffix}"
18+
19+
providers = {
20+
aws = aws.iam-management
21+
}
22+
}
23+
24+
module "iam_policies" {
25+
source = "git::[email protected]:tomarv2/terraform-aws-iam-policies.git?ref=v0.0.4"
26+
27+
count = var.existing_role_name == null ? 1 : 0
28+
29+
role_name = join("", module.iam_role.*.iam_role_name)
30+
policy = data.databricks_aws_crossaccount_policy.cross_account_iam_policy.json
31+
inline_policy = true
32+
# -----------------------------------------
33+
# Do not change the teamid, prjid once set.
34+
teamid = var.teamid
35+
prjid = "${var.prjid}-${local.suffix}"
36+
37+
providers = {
38+
aws = aws.iam-management
39+
}
40+
}

locals.tf

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
locals {
2+
region = data.aws_region.current.name
23
profile = var.profile_for_iam != null ? var.profile_for_iam : var.profile
34
}
5+
6+
data "aws_region" "current" {}

main.tf

100755100644
+12-55
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,17 @@
1-
module "vpc" {
2-
source = "git::[email protected]:tomarv2/terraform-aws-vpc.git?ref=v0.0.4"
1+
resource "databricks_mws_workspaces" "this" {
2+
provider = databricks.mws
33

4-
aws_region = var.aws_region
5-
enable_dns_hostnames = true
6-
enable_nat_gateway = true
7-
single_nat_gateway = true
8-
one_nat_gateway_per_az = false
9-
create_igw = true
10-
default_security_group_egress = [{
11-
cidr_blocks = "0.0.0.0/0"
12-
}]
4+
account_id = var.databricks_account_id
5+
aws_region = local.region
6+
workspace_name = "${var.teamid}-${var.prjid}"
7+
deployment_name = "${var.teamid}-${var.prjid}"
138

14-
default_security_group_ingress = [{
15-
description = "Allow all internal TCP and UDP"
16-
self = true
17-
}]
18-
19-
public_subnets = [cidrsubnet(var.cidr_block, 3, 0)]
20-
private_subnets = [cidrsubnet(var.cidr_block, 3, 1),
21-
cidrsubnet(var.cidr_block, 3, 2)]
22-
#------------------------------------------
23-
# Do not change the teamid, prjid once set.
24-
teamid = var.teamid
25-
prjid = var.prjid
9+
credentials_id = databricks_mws_credentials.this.credentials_id
10+
storage_configuration_id = databricks_mws_storage_configurations.this.storage_configuration_id
11+
network_id = databricks_mws_networks.this.network_id
2612
}
2713

28-
module "iam_role" {
29-
source = "git::[email protected]:tomarv2/terraform-aws-iam-role.git//modules/iam_role_external?ref=v0.0.7"
30-
31-
count = var.existing_role_name == null ? 1 : 0
32-
33-
assume_role_policy = data.databricks_aws_assume_role_policy.this.json
34-
# -----------------------------------------
35-
# Do not change the teamid, prjid once set.
36-
teamid = var.teamid
37-
prjid = "${var.prjid}-${local.suffix}"
38-
39-
providers = {
40-
aws = aws.iam-management
41-
}
42-
}
43-
44-
module "iam_policies" {
45-
source = "git::[email protected]:tomarv2/terraform-aws-iam-policies.git?ref=v0.0.4"
46-
47-
count = var.existing_role_name == null ? 1 : 0
48-
49-
role_name = join("", module.iam_role.*.iam_role_name)
50-
policy = data.databricks_aws_crossaccount_policy.cross_account_iam_policy.json
51-
inline_policy = true
52-
# -----------------------------------------
53-
# Do not change the teamid, prjid once set.
54-
teamid = var.teamid
55-
prjid = "${var.prjid}-${local.suffix}"
56-
57-
providers = {
58-
aws = aws.iam-management
59-
}
14+
resource "time_sleep" "wait" {
15+
depends_on = [module.iam_role]
16+
create_duration = "10s"
6017
}

s3.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "s3" {
2-
source = "git::[email protected]:tomarv2/terraform-aws-s3.git?ref=v0.0.7"
2+
source = "git::[email protected]:tomarv2/terraform-aws-s3.git?ref=v0.0.8"
33

44
custom_tags = var.custom_tags
55
# -----------------------------------------

variables.tf

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ variable "prjid" {
88
type = string
99
}
1010

11-
variable "profile" {
12-
description = "Getting values from ~/.aws/credentials"
13-
type = string
14-
default = "default"
15-
}
16-
17-
variable "aws_region" {
18-
description = "default aws region"
19-
type = string
20-
default = "us-west-2"
21-
}
22-
2311
variable "databricks_hostname" {
2412
description = "databricks hostname"
2513
type = string
@@ -51,12 +39,6 @@ locals {
5139
suffix = random_string.naming.result
5240
}
5341

54-
variable "profile_for_iam" {
55-
description = "profile to use for IAM"
56-
default = null
57-
type = string
58-
}
59-
6042
variable "existing_role_name" {
6143
description = "If you want to use existing role name, else a new role will be created"
6244
default = null
@@ -74,3 +56,21 @@ variable "custom_tags" {
7456
description = "Extra custom tags"
7557
default = null
7658
}
59+
60+
variable "profile" {
61+
description = "profile to use for resource creation"
62+
default = "default"
63+
type = string
64+
}
65+
66+
variable "profile_for_iam" {
67+
description = "profile to use for IAM"
68+
default = null
69+
type = string
70+
}
71+
72+
variable "region" {
73+
description = "AWS region to deploy resources"
74+
type = string
75+
default = "us-east-1"
76+
}

versions.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ terraform {
1818
}
1919

2020
provider "aws" {
21-
region = var.aws_region
21+
region = var.region
2222
profile = var.profile
2323
}
2424

2525
provider "aws" {
2626
alias = "iam-management"
2727

28-
region = var.aws_region
28+
region = var.region
2929
profile = local.profile
3030
}
3131

32+
3233
# initialize provider in "MWS" mode to provision new workspace
3334
provider "databricks" {
3435
alias = "mws"

vpc.tf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module "vpc" {
2+
source = "git::[email protected]:tomarv2/terraform-aws-vpc.git?ref=v0.0.6"
3+
4+
enable_dns_hostnames = true
5+
enable_nat_gateway = true
6+
single_nat_gateway = true
7+
one_nat_gateway_per_az = false
8+
create_igw = true
9+
10+
public_subnets = [cidrsubnet(var.cidr_block, 3, 0)]
11+
private_subnets = [cidrsubnet(var.cidr_block, 3, 1),
12+
cidrsubnet(var.cidr_block, 3, 2)]
13+
#------------------------------------------
14+
# Do not change the teamid, prjid once set.
15+
teamid = var.teamid
16+
prjid = var.prjid
17+
}

workspaces.tf

-17
This file was deleted.

0 commit comments

Comments
 (0)