-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpeerings.jinja
57 lines (54 loc) · 1.97 KB
/
peerings.jinja
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
resources:
{% for spoke in properties.spokes %}
{% set spokeName = spoke.name | default(spoke.url.split( "/" ) | last) %}
{% if properties.deleteSpokeDefaultRoutes %}
{# NOTE: this code will break if default route was already deleted and deleteDefaultROutes is set to true #}
- name: {{ spokeName }}-listDefaultRoutes
action: gcp-types/compute-v1:compute.routes.list
properties:
filter: (destRange="0.0.0.0/0") AND (network="{{ spoke.url }}")
- name: {{ spokeName }}-deleteDefaultRoute
action: gcp-types/compute-v1:compute.routes.delete
metadata:
runtimePolicy:
- CREATE
properties:
route: $(ref.{{ spokeName }}-listDefaultRoutes.items[0].name)
{% endif %}
- name: {{ properties.prefix }}-peer-{{ spokeName }}-to-hub
action: gcp-types/compute-v1:compute.networks.addPeering
properties:
network: {{ spokeName }}
networkPeering:
name: {{ properties.prefix }}-peer-{{ spokeName }}-to-hub
network: {{ properties.hub.url }}
exchangeSubnetRoutes: true
importCustomRoutes: true
metadata:
runtimePolicy:
- CREATE
dependsOn:
{% if properties.deleteSpokeDefaultRoutes %}
- {{ spokeName }}-deleteDefaultRoute
{% endif %}
{% if not loop.first %}
- {{ properties.prefix }}-peer-hub-to-{{ properties.spokes[loop.index0-1].name | default(properties.spokes[loop.index0-1].url.split('/') | last) }}
{% endif %}
{% for dependency in properties.dependsOn %}
- {{dependency}}
{% endfor %}
- name: {{ properties.prefix }}-peer-hub-to-{{ spokeName }}
action: gcp-types/compute-v1:compute.networks.addPeering
properties:
network: {{ properties.hub.name | default(properties.hub.url.split( '/' ) | last) }}
networkPeering:
name: {{ properties.prefix }}-peer-hub-to-{{ spokeName }}
network: {{ spoke.url }}
exchangeSubnetRoutes: true
exportCustomRoutes: true
metadata:
runtimePolicy:
- CREATE
dependsOn:
- {{ properties.prefix }}-peer-{{ spokeName }}-to-hub
{% endfor %}