-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_nsg.iql
More file actions
36 lines (33 loc) · 1.13 KB
/
example_nsg.iql
File metadata and controls
36 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*+ createorupdate */
INSERT INTO azure.network.security_groups(
networkSecurityGroupName,
resourceGroupName,
subscriptionId,
data__location,
data__properties,
data__tags
)
SELECT
'{{ nsg_name }}',
'{{ resource_group_name }}',
'{{ subscription_id }}',
'{{ location }}',
'{"securityRules":{{ security_rules }}}',
'{{ global_tags }}';
/*+ statecheck, retries=5, retry_delay=5 */
SELECT COUNT(*) as count FROM azure.network.security_groups
WHERE subscriptionId = '{{ subscription_id }}'
AND resourceGroupName = '{{ resource_group_name }}'
AND networkSecurityGroupName = '{{ nsg_name }}'
AND JSON_EXTRACT(properties, '$.securityRules') IS NOT NULL
/*+ exports */
SELECT id as network_security_group_id
FROM azure.network.security_groups
WHERE subscriptionId = '{{ subscription_id }}'
AND resourceGroupName = '{{ resource_group_name }}'
AND networkSecurityGroupName = '{{ nsg_name }}'
/*+ delete */
DELETE FROM azure.network.security_groups
WHERE subscriptionId = '{{ subscription_id }}'
AND resourceGroupName = '{{ resource_group_name }}'
AND networkSecurityGroupName = '{{ nsg_name }}'