Skip to content

Commit 5918099

Browse files
authored
Refactoring usage of providers within modules (#94)
* refactor providers usage within modules * remove more providers
1 parent 057c557 commit 5918099

File tree

37 files changed

+84
-428
lines changed

37 files changed

+84
-428
lines changed

examples/aws-remote-backend-infra/main.tf

+16-10
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ terraform {
1414

1515
resource "aws_s3_bucket" "terraform_state" {
1616
bucket = var.bucket_name
17-
# Enable versioning so we can see the full revision history of state files
18-
versioning {
19-
enabled = true
20-
}
2117
force_destroy = true
22-
# Enable server-side encryption by default
23-
server_side_encryption_configuration {
24-
rule {
25-
apply_server_side_encryption_by_default {
26-
sse_algorithm = "AES256"
27-
}
18+
}
19+
20+
# Enable versioning so we can see the full revision history of state files
21+
resource "aws_s3_bucket_versioning" "terraform_state" {
22+
bucket = aws_s3_bucket.terraform_state.id
23+
versioning_configuration {
24+
status = "Enabled"
25+
}
26+
}
27+
28+
# Enable server-side encryption by default
29+
resource "aws_s3_bucket_server_side_encryption_configuration" "terraform_state" {
30+
bucket = aws_s3_bucket.terraform_state.id
31+
rule {
32+
apply_server_side_encryption_by_default {
33+
sse_algorithm = "AES256"
2834
}
2935
}
3036
}

examples/aws-workspace-basic/main.tf

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module "aws-workspace-basic" {
22
source = "github.com/databricks/terraform-databricks-examples/modules/aws-workspace-basic"
33
databricks_account_id = var.databricks_account_id
4-
databricks_account_username = var.databricks_account_username
5-
databricks_account_password = var.databricks_account_password
64
}

examples/aws-workspace-basic/variables.tf

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
variable "databricks_account_username" {}
2-
variable "databricks_account_password" {}
31
variable "databricks_account_id" {}
42

53
variable "tags" {

examples/aws-workspace-basic/versions.tf

+8
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ terraform {
1212
}
1313
}
1414
}
15+
16+
provider "aws" {
17+
region = var.region
18+
}
19+
20+
provider "databricks" {
21+
host = "https://accounts.cloud.databricks.com"
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module "aws-workspace-with-firewall" {
22
source = "github.com/databricks/terraform-databricks-examples/modules/aws-workspace-with-firewall"
33
databricks_account_id = var.databricks_account_id
4-
databricks_account_username = var.databricks_account_username
5-
databricks_account_password = var.databricks_account_password
64
}

examples/aws-workspace-with-firewall/versions.tf

+8
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ terraform {
1212
}
1313
}
1414
}
15+
16+
provider "aws" {
17+
region = var.region
18+
}
19+
20+
provider "databricks" {
21+
host = "https://accounts.cloud.databricks.com"
22+
}

examples/gcp-basic/init.tf

+1-21
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,10 @@ provider "google" {
1313
project = var.google_project
1414
region = var.google_region
1515
zone = var.google_zone
16-
1716
}
1817

19-
20-
// initialize provider in "accounts" mode to provision new workspace
21-
2218
provider "databricks" {
23-
alias = "accounts"
2419
host = "https://accounts.gcp.databricks.com"
2520
google_service_account = var.databricks_google_service_account
2621
account_id = var.databricks_account_id
27-
28-
}
29-
30-
data "google_client_openid_userinfo" "me" {
31-
}
32-
33-
34-
data "google_client_config" "current" {
35-
}
36-
37-
38-
resource "random_string" "suffix" {
39-
special = false
40-
upper = false
41-
length = 6
42-
}
22+
}

examples/gcp-basic/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module "gcp-basic" {
2+
source = "github.com/databricks/terraform-databricks-examples/modules/gcp-workspace-basic"
3+
databricks_account_id = var.databricks_account_id
4+
google_project = var.google_project
5+
google_region = var.google_region
6+
prefix = var.prefix
7+
workspace_name = var.workspace_name
8+
delegate_from = var.delegate_from
9+
}

examples/gcp-basic/workspace.tf

-19
This file was deleted.

examples/gcp-byovpc/init.tf

+1-12
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ provider "google" {
1616

1717
}
1818

19-
20-
// initialize provider in "accounts" mode to provision new workspace
21-
2219
provider "databricks" {
23-
alias = "accounts"
2420
host = "https://accounts.gcp.databricks.com"
2521
google_service_account = var.databricks_google_service_account
2622
account_id = var.databricks_account_id
@@ -32,11 +28,4 @@ data "google_client_openid_userinfo" "me" {
3228

3329

3430
data "google_client_config" "current" {
35-
}
36-
37-
38-
resource "random_string" "suffix" {
39-
special = false
40-
upper = false
41-
length = 6
42-
}
31+
}

examples/gcp-byovpc/main.tf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "gcp-byovpc" {
2+
source = "github.com/databricks/terraform-databricks-examples/modules/gcp-workspace-byovpc"
3+
databricks_account_id = var.databricks_account_id
4+
google_project = var.google_project
5+
google_region = var.google_region
6+
prefix = var.prefix
7+
subnet_ip_cidr_range = var.subnet_ip_cidr_range
8+
pod_ip_cidr_range = var.pod_ip_cidr_range
9+
svc_ip_cidr_range = var.svc_ip_cidr_range
10+
subnet_name = var.subnet_name
11+
router_name = var.router_name
12+
nat_name = var.nat_name
13+
workspace_name = var.workspace_name
14+
delegate_from = var.delegate_from
15+
}

examples/gcp-byovpc/vpc.tf

-51
This file was deleted.

examples/gcp-byovpc/workspace.tf

-31
This file was deleted.

0 commit comments

Comments
 (0)