Skip to content

Commit 5d0cb45

Browse files
committed
infra udpates
1 parent 34776ab commit 5d0cb45

File tree

10 files changed

+29
-92
lines changed

10 files changed

+29
-92
lines changed

.github/workflows/databricks-dab.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ env:
3131
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}
3232
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }}
3333

34-
# # Databricks Workspace Credentials (set after infrastructure provisioning)
35-
# DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
36-
# DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
3734

3835
jobs:
3936

infrastructure/resources/aws/s3/s3_bucket.iql

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ WHERE
3636
region = '{{ region }}'
3737
AND data__Identifier = '{{ bucket_name }}'
3838

39-
/*+ statecheck, retries=3, retry_delay=5 */
40-
SELECT COUNT(*) as count FROM (
39+
/*+ exports, retries=3, retry_delay=5 */
40+
SELECT
41+
arn,
42+
bucket_name
43+
FROM (
4144
SELECT
45+
arn,
46+
bucket_name,
4247
JSON_EQUAL(ownership_controls, '{{ ownership_controls }}') as test_ownership_controls,
4348
JSON_EQUAL(bucket_encryption, '{{ bucket_encryption }}') as test_encryption,
4449
JSON_EQUAL(public_access_block_configuration, '{{ public_access_block_configuration }}') as test_public_access_block_configuration,
@@ -51,11 +56,3 @@ WHERE test_ownership_controls = 1
5156
AND test_encryption = 1
5257
AND test_public_access_block_configuration = 1
5358
AND test_versioning_configuration = 1
54-
55-
/*+ exports, retries=3, retry_delay=5 */
56-
SELECT
57-
arn,
58-
bucket_name
59-
FROM aws.s3.buckets
60-
WHERE region = '{{ region }}'
61-
AND data__Identifier = '{{ bucket_name }}'

infrastructure/resources/databricks_account/credentials.iql

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,15 @@ SELECT
1515
'{{ credentials_name }}',
1616
'{{ aws_credentials }}'
1717

18-
/*+ statecheck, retries=3, retry_delay=5 */
19-
SELECT COUNT(*) as count FROM
20-
(
21-
SELECT
22-
credentials_id
23-
FROM databricks_account.provisioning.credentials
24-
WHERE account_id = '{{ databricks_account_id }}'
25-
AND credentials_name = '{{ credentials_name }}'
26-
AND JSON_EXTRACT(aws_credentials, '$.sts_role.role_arn') = '{{ aws_iam_cross_account_role_arn }}'
27-
) t
28-
29-
/*+ exports */
18+
/*+ exports, retries=3, retry_delay=5 */
3019
SELECT
3120
'{{ credentials_name }}' as databricks_credentials_name,
3221
credentials_id as databricks_credentials_id,
3322
JSON_EXTRACT(aws_credentials, '$.sts_role.external_id') as databricks_role_external_id
3423
FROM databricks_account.provisioning.credentials
3524
WHERE account_id = '{{ databricks_account_id }}'
3625
AND credentials_name = '{{ credentials_name }}'
26+
AND JSON_EXTRACT(aws_credentials, '$.sts_role.role_arn') = '{{ aws_iam_cross_account_role_arn }}'
3727

3828
/*+ delete */
3929
DELETE FROM databricks_account.provisioning.credentials

infrastructure/resources/databricks_account/network.iql

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,21 @@ SELECT
1919
'{{ subnet_ids }}',
2020
'{{ security_group_ids }}'
2121

22-
/*+ statecheck, retries=3, retry_delay=5 */
23-
SELECT COUNT(*) as count FROM
24-
(
22+
/*+ exports, retries=3, retry_delay=5 */
23+
SELECT
24+
network_id as databricks_network_id
25+
FROM (
2526
SELECT
27+
network_id,
2628
JSON_EQUAL(subnet_ids, '{{ subnet_ids }}') as subnet_test,
2729
JSON_EQUAL(security_group_ids, '{{ security_group_ids }}') as sg_test
2830
FROM databricks_account.provisioning.networks
2931
WHERE account_id = '{{ databricks_account_id }}'
3032
AND network_name = '{{ databricks_network_name }}'
3133
AND vpc_id = '{{ vpc_id }}'
32-
AND subnet_test = 1
33-
AND sg_test = 1
3434
)t
35-
36-
/*+ exports */
37-
SELECT
38-
network_id as databricks_network_id
39-
FROM databricks_account.provisioning.networks
40-
WHERE account_id = '{{ databricks_account_id }}' AND
41-
network_name = '{{ databricks_network_name }}'
35+
WHERE subnet_test = 1
36+
AND sg_test = 1
4237

4338
/*+ delete */
4439
DELETE FROM databricks_account.provisioning.networks

infrastructure/resources/databricks_account/storage_configuration.iql

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@ SELECT
1515
'{{ storage_configuration_name }}',
1616
'{{ root_bucket_info }}'
1717

18-
/*+ statecheck, retries=3, retry_delay=5 */
19-
SELECT COUNT(*) as count
20-
FROM databricks_account.provisioning.storage
21-
WHERE account_id = '{{ databricks_account_id }}'
22-
AND storage_configuration_name = '{{ storage_configuration_name }}'
23-
AND JSON_EXTRACT(root_bucket_info, '$.bucket_name') = '{{ aws_s3_workspace_bucket_name }}'
24-
25-
/*+ exports */
18+
/*+ exports, retries=3, retry_delay=5 */
2619
SELECT
2720
storage_configuration_id as databricks_storage_configuration_id
2821
FROM databricks_account.provisioning.storage
2922
WHERE account_id = '{{ databricks_account_id }}'
3023
AND storage_configuration_name = '{{ storage_configuration_name }}'
24+
AND JSON_EXTRACT(root_bucket_info, '$.bucket_name') = '{{ aws_s3_workspace_bucket_name }}'
3125

3226
/*+ delete */
3327
DELETE FROM databricks_account.provisioning.storage

infrastructure/resources/databricks_account/workspace.iql

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,18 @@ SELECT
2121
'{{ storage_configuration_id }}',
2222
'{{ pricing_tier }}'
2323

24-
/*+ statecheck, retries=3, retry_delay=5 */
25-
SELECT COUNT(*) as count
26-
FROM databricks_account.provisioning.workspaces
27-
WHERE account_id = '{{ databricks_account_id }}'
28-
AND workspace_name = '{{ workspace_name }}'
29-
AND aws_region = '{{ aws_region }}'
30-
AND credentials_id = '{{ credentials_id }}'
31-
AND storage_configuration_id = '{{ storage_configuration_id }}'
32-
AND pricing_tier = '{{ pricing_tier }}'
33-
34-
/*+ exports */
24+
/*+ exports, retries=3, retry_delay=5 */
3525
SELECT
3626
'{{ workspace_name }}' AS databricks_workspace_name,
3727
workspace_id AS databricks_workspace_id,
3828
deployment_name AS databricks_deployment_name
3929
FROM databricks_account.provisioning.workspaces
4030
WHERE account_id = '{{ databricks_account_id }}'
4131
AND workspace_name = '{{ workspace_name }}'
32+
AND aws_region = '{{ aws_region }}'
33+
AND credentials_id = '{{ credentials_id }}'
34+
AND storage_configuration_id = '{{ storage_configuration_id }}'
35+
AND pricing_tier = '{{ pricing_tier }}'
4236

4337
/*+ delete */
4438
DELETE FROM databricks_account.provisioning.workspaces

infrastructure/resources/databricks_account/workspace_group.iql

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ SELECT
1313
'{{ databricks_account_id }}',
1414
'{{ display_name }}'
1515

16-
/*+ statecheck, retries=3, retry_delay=5 */
17-
SELECT COUNT(*) as count
18-
FROM databricks_account.iam.groups
19-
WHERE account_id = '{{ databricks_account_id }}'
20-
AND displayName = '{{ display_name }}'
21-
22-
/*+ exports */
16+
/*+ exports, retries=3, retry_delay=5 */
2317
SELECT id AS databricks_group_id,
2418
displayName AS databricks_group_name
2519
FROM databricks_account.iam.groups

infrastructure/resources/databricks_workspace/external_location.iql

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,15 @@ SELECT
2424
{{ skip_validation }}
2525
;
2626

27-
/*+ statecheck, retries=3, retry_delay=5 */
28-
SELECT COUNT(*) as count
27+
/*+ exports, retries=3, retry_delay=5 */
28+
SELECT name as external_location_name
2929
FROM databricks_workspace.unitycatalog.external_locations
3030
WHERE name = '{{ name | replace('-', '_') }}' AND
3131
deployment_name = '{{ databricks_deployment_name }}'
3232
AND url = '{{ url }}' AND
3333
credential_name = '{{ credential_name | replace('-', '_') }}' AND
3434
read_only = {{ read_only }} AND
3535
comment = '{{ comment }}';
36-
37-
/*+ exports */
38-
SELECT name as external_location_name
39-
FROM databricks_workspace.unitycatalog.external_locations
40-
WHERE name = '{{ name | replace('-', '_') }}' AND
41-
deployment_name = '{{ databricks_deployment_name }}'
4236

4337
/*+ delete */
4438
DELETE FROM databricks_workspace.unitycatalog.external_locations

infrastructure/resources/databricks_workspace/storage_credential.iql

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,14 @@ SELECT
2222
'{{ skip_validation }}'
2323
;
2424

25-
/*+ statecheck, retries=3, retry_delay=5 */
26-
SELECT COUNT(*) as count
27-
FROM databricks_workspace.unitycatalog.storage_credentials
28-
WHERE name = '{{ name | replace('-', '_') | upper }}' AND
29-
deployment_name = '{{ databricks_deployment_name }}' AND
30-
JSON_EXTRACT(aws_iam_role, '$.role_arn') = '{{ metastore_access_role_arn }}';
31-
32-
/*+ exports */
25+
/*+ exports, retries=3, retry_delay=5 */
3326
SELECT
3427
name as storage_credential_name,
3528
JSON_EXTRACT(aws_iam_role, '$.external_id') as storage_credential_external_id
3629
FROM databricks_workspace.unitycatalog.storage_credentials
3730
WHERE name = '{{ name | replace('-', '_') | upper }}' AND
38-
deployment_name = '{{ databricks_deployment_name }}';
31+
deployment_name = '{{ databricks_deployment_name }}' AND
32+
JSON_EXTRACT(aws_iam_role, '$.role_arn') = '{{ metastore_access_role_arn }}';
3933

4034
/*+ delete */
4135
DELETE FROM databricks_workspace.unitycatalog.storage_credentials

infrastructure/stackql_manifest.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ resources:
188188
- bucket_name: aws_s3_workspace_bucket_name
189189

190190
- name: aws/s3/workspace_bucket_policy
191-
if: "'env' == '{{ stack_env }}'"
192191
file: aws/s3/s3_bucket_policy.iql
193192
props:
194193
- name: policy_document
@@ -225,7 +224,6 @@ resources:
225224
# ====================================================================================
226225

227226
- name: aws/s3/metastore_bucket
228-
if: "'env' == '{{ stack_env }}'"
229227
file: aws/s3/s3_bucket.iql
230228
props:
231229
- name: bucket_name
@@ -254,7 +252,6 @@ resources:
254252
- bucket_name: aws_s3_metastore_bucket_name
255253

256254
- name: aws/iam/metastore_access_role
257-
if: "'env' == '{{ stack_env }}'"
258255
file: aws/iam/iam_role.iql
259256
props:
260257
- name: role_name
@@ -387,7 +384,6 @@ resources:
387384
- databricks_deployment_name
388385

389386
- name: databricks_account/workspace_group
390-
if: "'env' == '{{ stack_env }}'"
391387
props:
392388
- name: display_name
393389
value: "{{ stack_name }}-{{ stack_env }}-workspace-admins"
@@ -396,7 +392,6 @@ resources:
396392
- databricks_group_name
397393

398394
- name: databricks_account/get_users
399-
if: "'env' == '{{ stack_env }}'"
400395
type: query
401396
props:
402397
- name: users
@@ -407,16 +402,13 @@ resources:
407402
- databricks_workspace_group_members
408403

409404
- name: databricks_account/update_group_membership
410-
if: "'env' == '{{ stack_env }}'"
411405
type: command
412406
props: []
413407

414408
- name: databricks_account/workspace_permission_assignments
415-
if: "'env' == '{{ stack_env }}'"
416409
props: []
417410

418411
- name: databricks_workspace/storage_credential
419-
if: "'env' == '{{ stack_env }}'"
420412
props:
421413
- name: name
422414
value: "{{ stack_name }}_{{ stack_env }}_storage_credential"
@@ -434,7 +426,6 @@ resources:
434426
- storage_credential_external_id
435427

436428
- name: aws/iam/update_metastore_access_role
437-
if: "'env' == '{{ stack_env }}'"
438429
type: command
439430
props:
440431
- name: role_name
@@ -454,7 +445,6 @@ resources:
454445
sts:ExternalId: "{{ storage_credential_external_id }}"
455446

456447
- name: databricks_workspace/unitycatalog/credential_grants
457-
if: "'env' == '{{ stack_env }}'"
458448
type: command
459449
props:
460450
- name: privileges
@@ -469,7 +459,6 @@ resources:
469459
deployment_name = '{{ databricks_deployment_name }}';
470460
471461
- name: databricks_workspace/external_location
472-
if: "'env' == '{{ stack_env }}'"
473462
props:
474463
- name: name
475464
value: "{{ stack_name }}_{{ stack_env }}_external_location"
@@ -487,7 +476,6 @@ resources:
487476
- external_location_name
488477

489478
- name: databricks_workspace/unitycatalog/location_grants
490-
if: "'env' == '{{ stack_env }}'"
491479
type: command
492480
props:
493481
- name: privileges

0 commit comments

Comments
 (0)