-
Notifications
You must be signed in to change notification settings - Fork 3
/
firewall.py
38 lines (34 loc) · 1.24 KB
/
firewall.py
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
37
38
def generate_config(context):
properties = context.properties
external_firewall_name = context.env['deployment'] + '-external'
internal_firewall_name = context.env['deployment'] + '-internal'
firewall_external = {
'name': external_firewall_name,
'type': 'compute.v1.firewall',
'properties': {
'sourceRanges': ['0.0.0.0/0'],
'network': properties['networkRef'],
'targetTags': [external_firewall_name],
'allowed': [{
'IPProtocol': 'tcp',
'ports': ['22', '7473', '7474', '7687', '6362', '2003', '2004', '3637']
}]
}
}
firewall_internal = {
'name': internal_firewall_name,
'type': 'compute.v1.firewall',
'properties': {
'sourceRanges': [properties['subnetCidr']],
'network': properties['networkRef'],
'targetTags': [internal_firewall_name],
'allowed': [{
'IPProtocol': 'tcp',
'ports': ['5000', '6000', '7000', '7688']
}]
}
}
config = {'resources': [], 'outputs': []}
config['resources'].append(firewall_internal)
config['resources'].append(firewall_external)
return config