Skip to content

Commit 737000a

Browse files
committed
Update AWS testing environments
1 parent a0ef849 commit 737000a

File tree

9 files changed

+108
-198
lines changed

9 files changed

+108
-198
lines changed

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ test-gcp-accounts: install
6262
@echo "✓ Running acceptance Tests for Multiple Workspace APIs on GCP..."
6363
@/bin/bash scripts/run.sh gcp-accounts '^TestGcpAcc' --debug --tee
6464

65-
test-awsst: install
66-
@echo "✓ Running Terraform Acceptance Tests for AWS ST..."
67-
@/bin/bash scripts/run.sh awsst '^(TestAcc|TestAwsAcc)' --debug --tee
68-
6965
test-awsmt: install
7066
@echo "✓ Running Terraform Acceptance Tests for AWS MT..."
7167
@/bin/bash scripts/run.sh awsmt '^(TestAcc|TestAwsAcc)' --debug --tee
@@ -74,8 +70,4 @@ test-preview: install
7470
@echo "✓ Running acceptance Tests for Preview features..."
7571
@/bin/bash scripts/run.sh preview '^TestPreviewAcc' --debug --tee
7672

77-
snapshot:
78-
@echo "✓ Making Snapshot ..."
79-
@goreleaser release --rm-dist --snapshot
80-
8173
.PHONY: build fmt python-setup docs vendor build fmt coverage test lint

docs/guides/aws-workspace.md

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ resource "databricks_mws_credentials" "this" {
111111

112112
## VPC
113113

114-
The very first step is VPC creation with necessary firewall rules. Please consult [main documetation page](https://docs.databricks.com/administration-guide/cloud-configurations/aws/customer-managed-vpc.html) for **the most complete and up-to-date details on networking**. AWS VPS is registered as [databricks_mws_networks](../resources/mws_networks.md) resource.
114+
The very first step is VPC creation with necessary firewall rules. Please consult [main documetation page](https://docs.databricks.com/administration-guide/cloud-configurations/aws/customer-managed-vpc.html) for **the most complete and up-to-date details on networking**. AWS VPS is registered as [databricks_mws_networks](../resources/mws_networks.md) resource. For STS, S3 and Kinesis, you can create VPC gateway or interface endpoints such that the relevant in-region traffic from clusters could transit over the secure AWS backbone rather than the public network, for more direct connections and reduced cost compared to AWS global endpoints. For more information, see [Regional endpoints]
115+
](https://docs.databricks.com/administration-guide/cloud-configurations/aws/customer-managed-vpc.html#regional-endpoints-1).
115116

116117
```hcl
117118
data "aws_availability_zones" "available" {}
@@ -146,52 +147,6 @@ module "vpc" {
146147
}]
147148
}
148149
149-
resource "databricks_mws_networks" "this" {
150-
provider = databricks.mws
151-
account_id = var.databricks_account_id
152-
network_name = "${local.prefix}-network"
153-
security_group_ids = [module.vpc.default_security_group_id]
154-
subnet_ids = module.vpc.private_subnets
155-
vpc_id = module.vpc.vpc_id
156-
}
157-
```
158-
159-
## Regional endpoints
160-
161-
For STS, S3 and Kinesis, you can create VPC gateway or interface endpoints such that the relevant in-region traffic from clusters could transit over the secure AWS backbone rather than the public network, for more direct connections and reduced cost compared to AWS global endpoints. See [Regional endpoints]
162-
](https://docs.databricks.com/administration-guide/cloud-configurations/aws/customer-managed-vpc.html#regional-endpoints-1) for more information:
163-
164-
```hcl
165-
module "vpc" {
166-
source = "terraform-aws-modules/vpc/aws"
167-
version = "3.2.0"
168-
169-
name = local.prefix
170-
cidr = var.cidr_block
171-
azs = data.aws_availability_zones.available.names
172-
tags = var.tags
173-
174-
enable_dns_hostnames = true
175-
enable_nat_gateway = true
176-
create_igw = true
177-
178-
public_subnets = [cidrsubnet(var.cidr_block, 3, 0)]
179-
private_subnets = [cidrsubnet(var.cidr_block, 3, 1),
180-
cidrsubnet(var.cidr_block, 3, 2)]
181-
182-
manage_default_security_group = true
183-
default_security_group_name = "${local.prefix}-sg"
184-
185-
default_security_group_egress = [{
186-
cidr_blocks = "0.0.0.0/0"
187-
}]
188-
189-
default_security_group_ingress = [{
190-
description = "Allow all internal TCP and UDP"
191-
self = true
192-
}]
193-
}
194-
195150
module "vpc_endpoints" {
196151
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
197152
version = "3.2.0"
@@ -203,7 +158,9 @@ module "vpc_endpoints" {
203158
s3 = {
204159
service = "s3"
205160
service_type = "Gateway"
206-
route_table_ids = flatten([module.vpc.private_route_table_ids, module.vpc.public_route_table_ids])
161+
route_table_ids = flatten([
162+
module.vpc.private_route_table_ids,
163+
module.vpc.public_route_table_ids])
207164
tags = {
208165
Name = "${local.prefix}-s3-vpc-endpoint"
209166
}
@@ -228,6 +185,15 @@ module "vpc_endpoints" {
228185
229186
tags = var.tags
230187
}
188+
189+
resource "databricks_mws_networks" "this" {
190+
provider = databricks.mws
191+
account_id = var.databricks_account_id
192+
network_name = "${local.prefix}-network"
193+
security_group_ids = [module.vpc.default_security_group_id]
194+
subnet_ids = module.vpc.private_subnets
195+
vpc_id = module.vpc.vpc_id
196+
}
231197
```
232198

233199
## Root bucket

scripts/awsmt-integration/main.tf

Lines changed: 90 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ data "external" "env" {
22
program = ["python", "-c", "import sys,os,json;json.dump(dict(os.environ), sys.stdout)"]
33
}
44

5-
provider "aws" {
6-
region = data.external.env.result.TEST_REGION
7-
}
8-
95
resource "random_string" "naming" {
106
special = false
117
upper = false
@@ -14,14 +10,21 @@ resource "random_string" "naming" {
1410

1511
locals {
1612
// dltp - databricks labs terraform provider
17-
prefix = "dltp${random_string.naming.result}"
13+
prefix = "dltp${random_string.naming.result}"
14+
cidr_block = data.external.env.result.TEST_CIDR
15+
region = data.external.env.result.TEST_REGION
16+
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
1817
tags = {
1918
Environment = "Testing"
2019
Owner = data.external.env.result.OWNER
2120
Epoch = random_string.naming.result
2221
}
2322
}
2423

24+
provider "aws" {
25+
region = local.region
26+
}
27+
2528
// initialize provider in "MWS" mode to provision new workspace
2629
provider "databricks" {
2730
alias = "mws"
@@ -30,7 +33,7 @@ provider "databricks" {
3033

3134
data "databricks_aws_assume_role_policy" "this" {
3235
provider = databricks.mws
33-
external_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
36+
external_id = local.account_id
3437
}
3538

3639
resource "aws_iam_role" "cross_account_role" {
@@ -53,7 +56,7 @@ resource "aws_iam_role_policy" "this" {
5356
// register cross-account ARN
5457
resource "databricks_mws_credentials" "this" {
5558
provider = databricks.mws
56-
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
59+
account_id = local.account_id
5760
role_arn = aws_iam_role.cross_account_role.arn
5861
credentials_name = "${local.prefix}-creds"
5962

@@ -63,35 +66,106 @@ resource "databricks_mws_credentials" "this" {
6366

6467
module "this" {
6568
source = "../modules/aws-mws-common"
66-
cidr_block = data.external.env.result.TEST_CIDR
67-
region = data.external.env.result.TEST_REGION
69+
cidr_block = local.cidr_block
70+
region = local.region
6871
prefix = local.prefix
6972
tags = local.tags
7073
}
7174

7275
// register root bucket
7376
resource "databricks_mws_storage_configurations" "this" {
7477
provider = databricks.mws
75-
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
78+
account_id = local.account_id
7679
bucket_name = module.this.root_bucket
7780
storage_configuration_name = "${local.prefix}-storage"
7881
}
7982

8083
// register VPC
84+
data "aws_availability_zones" "available" {}
85+
86+
module "vpc" {
87+
source = "terraform-aws-modules/vpc/aws"
88+
version = "3.2.0"
89+
90+
name = local.prefix
91+
cidr = local.cidr_block
92+
azs = data.aws_availability_zones.available.names
93+
tags = local.tags
94+
95+
enable_dns_hostnames = true
96+
enable_nat_gateway = true
97+
create_igw = true
98+
99+
public_subnets = [cidrsubnet(local.cidr_block, 3, 0)]
100+
private_subnets = [cidrsubnet(local.cidr_block, 3, 1),
101+
cidrsubnet(local.cidr_block, 3, 2)]
102+
103+
manage_default_security_group = true
104+
default_security_group_name = "${local.prefix}-sg"
105+
106+
default_security_group_egress = [{
107+
cidr_blocks = "0.0.0.0/0"
108+
}]
109+
110+
default_security_group_ingress = [{
111+
description = "Allow all internal TCP and UDP"
112+
self = true
113+
}]
114+
}
115+
116+
module "vpc_endpoints" {
117+
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
118+
version = "3.2.0"
119+
120+
vpc_id = module.vpc.vpc_id
121+
security_group_ids = [module.vpc.default_security_group_id]
122+
123+
endpoints = {
124+
s3 = {
125+
service = "s3"
126+
service_type = "Gateway"
127+
route_table_ids = flatten([
128+
module.vpc.private_route_table_ids,
129+
module.vpc.public_route_table_ids])
130+
tags = {
131+
Name = "${local.prefix}-s3-vpc-endpoint"
132+
}
133+
},
134+
sts = {
135+
service = "sts"
136+
private_dns_enabled = true
137+
subnet_ids = module.vpc.private_subnets
138+
tags = {
139+
Name = "${local.prefix}-sts-vpc-endpoint"
140+
}
141+
},
142+
kinesis-streams = {
143+
service = "kinesis-streams"
144+
private_dns_enabled = true
145+
subnet_ids = module.vpc.private_subnets
146+
tags = {
147+
Name = "${local.prefix}-kinesis-vpc-endpoint"
148+
}
149+
},
150+
}
151+
152+
tags = local.tags
153+
}
154+
81155
resource "databricks_mws_networks" "this" {
82156
provider = databricks.mws
83-
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
157+
account_id = local.account_id
84158
network_name = "${local.prefix}-network"
85-
subnet_ids = [module.this.subnet_public, module.this.subnet_private]
86-
vpc_id = module.this.vpc_id
87-
security_group_ids = [module.this.security_group]
159+
security_group_ids = [module.vpc.default_security_group_id]
160+
subnet_ids = module.vpc.private_subnets
161+
vpc_id = module.vpc.vpc_id
88162
}
89163

90164
// create workspace in given VPC with DBFS on root bucket
91165
resource "databricks_mws_workspaces" "this" {
92166
provider = databricks.mws
93-
account_id = data.external.env.result.DATABRICKS_ACCOUNT_ID
94-
aws_region = data.external.env.result.TEST_REGION
167+
account_id = local.account_id
168+
aws_region = local.region
95169
workspace_name = local.prefix
96170
deployment_name = local.prefix
97171

scripts/awsst-integration/main.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/awsst-integration/require_env

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/modules/aws-mws-common/vpc.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ resource "aws_route_table" "private" {
112112
})
113113
}
114114

115+
output "private_rt" {
116+
value = aws_route_table.private.id
117+
}
118+
115119
resource "aws_route_table_association" "private" {
116120
route_table_id = aws_route_table.private.id
117121
subnet_id = aws_subnet.private.id

scripts/mws-integration/templates/cross_account_role_assume_policy.tpl

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/mws-integration/templates/cross_account_role_policy.tpl

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)