Skip to content

Commit c6bc6ef

Browse files
committed
fixed databricks example
1 parent 1cd440f commit c6bc6ef

File tree

9 files changed

+413
-49
lines changed

9 files changed

+413
-49
lines changed

examples/databricks/all-purpose-cluster/resources/aws/iam/cross_account_role.iql renamed to examples/databricks/all-purpose-cluster/resources/aws/iam/iam_role.iql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ AND path = '{{ path }}';
4949

5050
/*+ exports, retries=3, retry_delay=5 */
5151
SELECT
52-
arn as aws_iam_cross_account_role_arn
52+
arn as aws_iam_role_arn
5353
FROM aws.iam.roles
5454
WHERE data__Identifier = '{{ role_name }}'
5555

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*+ exports, retries=3, retry_delay=5 */
22
SELECT
3-
route_table_id
3+
route_table_id as main_route_table_id
44
FROM aws.ec2.route_tables
55
WHERE region = '{{ region }}'
66
AND vpc_id = '{{ vpc_id }}';

examples/databricks/all-purpose-cluster/resources/aws/vpc/nat_gateway.iql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INSERT INTO aws.ec2.nat_gateways (
2020
)
2121
SELECT
2222
'{{ eip_allocation_id }}',
23-
'{{ aws_vpc_subnet1_id }}',
23+
'{{ nat_subnet_id }}',
2424
'{{ tags }}',
2525
'{{ region }}';
2626

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*+ exists */
2+
SELECT COUNT(*) as count FROM
3+
(
4+
SELECT data__Identifier
5+
FROM aws.ec2.routes
6+
WHERE region = '{{ region }}'
7+
AND data__Identifier = '{{ route_table_id }}|0.0.0.0/0'
8+
) t
9+
10+
/*+ create */
11+
INSERT INTO aws.ec2.routes (
12+
DestinationCidrBlock,
13+
NatGatewayId,
14+
RouteTableId,
15+
region
16+
)
17+
SELECT
18+
'0.0.0.0/0',
19+
'{{ nat_gateway_id }}',
20+
'{{ route_table_id }}',
21+
'{{ region }}';
22+
23+
/*+ statecheck, retries=5, retry_delay=5 */
24+
SELECT COUNT(*) as count FROM
25+
(
26+
SELECT data__Identifier
27+
FROM aws.ec2.routes
28+
WHERE region = '{{ region }}'
29+
AND data__Identifier = '{{ route_table_id }}|0.0.0.0/0'
30+
) t
31+
32+
/*+ exports, retries=3, retry_delay=5 */
33+
SELECT data__Identifier as nat_inet_route_indentifer
34+
FROM aws.ec2.routes
35+
WHERE region = '{{ region }}'
36+
AND data__Identifier = '{{ route_table_id }}|0.0.0.0/0';
37+
38+
/*+ delete */
39+
DELETE FROM aws.ec2.routes
40+
WHERE data__Identifier = '{{ inet_route_indentifer }}'
41+
AND region = '{{ region }}';
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*+ exists */
2+
SELECT COUNT(*) as count FROM
3+
(
4+
SELECT route_table_id,
5+
json_group_object(tag_key, tag_value) as tags
6+
FROM aws.ec2.route_table_tags
7+
WHERE region = '{{ region }}'
8+
GROUP BY route_table_id
9+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
10+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
11+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
12+
AND json_extract(tags, '$.Name') = '{{ route_table_name }}'
13+
) t
14+
15+
/*+ create */
16+
INSERT INTO aws.ec2.route_tables (
17+
VpcId,
18+
Tags,
19+
region
20+
)
21+
SELECT
22+
'{{ vpc_id }}',
23+
'{{ tags }}',
24+
'{{ region }}';
25+
26+
/*+ statecheck, retries=3, retry_delay=5 */
27+
SELECT COUNT(*) as count FROM
28+
(
29+
SELECT route_table_id,
30+
json_group_object(tag_key, tag_value) as tags
31+
FROM aws.ec2.route_table_tags
32+
WHERE region = '{{ region }}'
33+
GROUP BY route_table_id
34+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
35+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
36+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
37+
AND json_extract(tags, '$.Name') = '{{ route_table_name }}'
38+
) t
39+
40+
/*+ exports, retries=3, retry_delay=5 */
41+
SELECT route_table_id,
42+
json_group_object(tag_key, tag_value) as tags
43+
FROM aws.ec2.route_table_tags
44+
WHERE region = '{{ region }}'
45+
GROUP BY route_table_id
46+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
47+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
48+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
49+
AND json_extract(tags, '$.Name') = '{{ route_table_name }}'
50+
51+
/*+ delete */
52+
DELETE FROM aws.ec2.route_tables
53+
WHERE data__Identifier = '{{ route_table_id }}'
54+
AND region = '{{ region }}';

examples/databricks/all-purpose-cluster/resources/aws/vpc/tag_main_vpc_route_table.iql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set data__PatchDocument = string('{{ {
44
"Tags": tags
55
} | generate_patch_document }}')
66
WHERE region = '{{ region }}'
7-
AND data__Identifier = '{{ route_table_id }}';
7+
AND data__Identifier = '{{ main_route_table_id }}';
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*+ exists */
2+
SELECT COUNT(*) as count FROM
3+
(
4+
SELECT id,
5+
json_group_object(tag_key, tag_value) as tags
6+
FROM aws.ec2.vpc_endpoint_tags
7+
WHERE region = '{{ region }}'
8+
AND service_name = '{{ service_name }}'
9+
GROUP BY id
10+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
11+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
12+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
13+
) t;
14+
15+
/*+ create */
16+
INSERT INTO aws.ec2.vpc_endpoints (
17+
ServiceName,
18+
VpcEndpointType,
19+
VpcId,
20+
RouteTableIds,
21+
Tags,
22+
region
23+
)
24+
SELECT
25+
'{{ service_name }}',
26+
'{{ vpc_endpoint_type }}',
27+
'{{ vpc_id }}',
28+
'{{ route_table_ids }}',
29+
'{{ tags }}',
30+
'{{ region }}';
31+
32+
/*+ statecheck, retries=5, retry_delay=5 */
33+
SELECT COUNT(*) as count FROM
34+
(
35+
SELECT id,
36+
json_group_object(tag_key, tag_value) as tags
37+
FROM aws.ec2.vpc_endpoint_tags
38+
WHERE region = '{{ region }}'
39+
AND service_name = '{{ service_name }}'
40+
GROUP BY id
41+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
42+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
43+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
44+
) t;
45+
46+
/*+ exports, retries=3, retry_delay=5 */
47+
SELECT id as s3_gateway_endpoint_id,
48+
json_group_object(tag_key, tag_value) as tags
49+
FROM aws.ec2.vpc_endpoint_tags
50+
WHERE region = '{{ region }}'
51+
AND service_name = '{{ service_name }}'
52+
GROUP BY id
53+
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
54+
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
55+
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}';
56+
57+
/*+ delete */
58+
DELETE FROM aws.ec2.vpc_endpoints
59+
WHERE data__Identifier = 's3_gateway_endpoint_id'
60+
AND region = 'us-east-1';

examples/databricks/all-purpose-cluster/resources/databricks_account/workspace.iql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ AND workspace_name = '{{ workspace_name }}'
88
INSERT INTO databricks_account.provisioning.workspaces (
99
account_id,
1010
data__workspace_name,
11-
data__network_id,
1211
data__aws_region,
1312
data__credentials_id,
1413
data__storage_configuration_id,
@@ -17,7 +16,6 @@ data__pricing_tier
1716
SELECT
1817
'{{ databricks_account_id }}',
1918
'{{ workspace_name }}',
20-
'{{ network_id }}',
2119
'{{ aws_region }}',
2220
'{{ credentials_id }}',
2321
'{{ storage_configuration_id }}',
@@ -28,14 +26,14 @@ SELECT COUNT(*) as count
2826
FROM databricks_account.provisioning.workspaces
2927
WHERE account_id = '{{ databricks_account_id }}'
3028
AND workspace_name = '{{ workspace_name }}'
31-
AND network_id = '{{ network_id }}'
3229
AND aws_region = '{{ aws_region }}'
3330
AND credentials_id = '{{ credentials_id }}'
3431
AND storage_configuration_id = '{{ storage_configuration_id }}'
3532
AND pricing_tier = '{{ pricing_tier }}'
3633

3734
/*+ exports */
38-
SELECT workspace_id AS databricks_workspace_id
35+
SELECT workspace_id AS databricks_workspace_id,
36+
deployment_name AS databricks_deployment_name
3937
FROM databricks_account.provisioning.workspaces
4038
WHERE account_id = '{{ databricks_account_id }}'
4139
AND workspace_name = '{{ workspace_name }}'

0 commit comments

Comments
 (0)