proxy_fastly: set urls

This commit is contained in:
Iain Learmonth 2022-06-23 21:05:01 +01:00
parent 2f3feca27a
commit 371c287f3e

View file

@ -1,5 +1,7 @@
from typing import Any
from typing import Any, Optional
from app.extensions import db
from app.models.mirrors import Proxy
from app.terraform.proxy import ProxyAutomation
@ -42,7 +44,7 @@ class ProxyFastlyAutomation(ProxyAutomation):
module "label_{{ group.id }}" {
source = "cloudposse/label/null"
version = "0.25.0"
namespace = "bc"
namespace = "{{ global_namespace }}"
tenant = "{{ group.group_name }}"
label_order = ["namespace", "tenant", "name", "attributes"]
}
@ -59,7 +61,6 @@ class ProxyFastlyAutomation(ProxyAutomation):
expiration_days = 90
}
{% if group.id == 3 %}
{% for subgroup in subgroups[group.id] %}
resource "fastly_service_vcl" "service_{{ group.id }}_{{ subgroup }}" {
name = "${module.label_{{ group.id }}.id}-{{ subgroup }}"
@ -108,10 +109,14 @@ class ProxyFastlyAutomation(ProxyAutomation):
}
}
{% endfor %}{# subgroup #}
{% endif %}{# group.id == 3 #}
{% endfor %}{# group #}
"""
def import_state(self, state: Any) -> None:
pass
def import_state(self, state: Optional[Any]) -> None:
proxies = Proxy.query.filter(
Proxy.provider == self.provider,
Proxy.destroyed.is_(None)
).all()
for proxy in proxies:
proxy.url = f"https://{{ proxy.slug }}.global.ssl.fastly.net"
db.session.commit()