terraform: generate conf with http backend
This commit is contained in:
parent
affa0f0149
commit
32239c379a
16 changed files with 43 additions and 4 deletions
|
@ -39,6 +39,10 @@ def update_smart_proxy_instance(group_id: int,
|
|||
instance.instance_id = instance_id
|
||||
|
||||
|
||||
def sp_trusted_prefixes() -> str:
|
||||
return "\n".join([f"geoip2_proxy {p};" for p in all_cdn_prefixes()])
|
||||
|
||||
|
||||
class ProxyAutomation(TerraformAutomation):
|
||||
subgroup_max = math.inf
|
||||
"""
|
||||
|
@ -154,14 +158,16 @@ class ProxyAutomation(TerraformAutomation):
|
|||
Proxy.provider == self.provider, Proxy.destroyed.is_(None)).all(), subgroups=self.get_subgroups(),
|
||||
global_namespace=app.config['GLOBAL_NAMESPACE'], bypass_token=app.config['BYPASS_TOKEN'],
|
||||
terraform_modules_path=os.path.join(*list(os.path.split(app.root_path))[:-1], 'terraform-modules'),
|
||||
backend_config=f"""backend "http" {{
|
||||
lock_address = "{app.config['TFSTATE_BACKEND']}/{self.short_name}"
|
||||
unlock_address = "{app.config['TFSTATE_BACKEND']}/{self.short_name}"
|
||||
address = "{app.config['TFSTATE_BACKEND']}/{self.short_name}"
|
||||
}}""",
|
||||
**{k: app.config[k.upper()] for k in self.template_parameters})
|
||||
if self.smart_proxies:
|
||||
for group in groups:
|
||||
self.sp_config(group)
|
||||
|
||||
def sp_trusted_prefixes(self) -> str:
|
||||
return "\n".join([f"geoip2_proxy {p};" for p in all_cdn_prefixes()])
|
||||
|
||||
def sp_config(self, group: Group) -> None:
|
||||
group_origins: List[Origin] = Origin.query.filter(
|
||||
Origin.group_id == group.id,
|
||||
|
@ -174,7 +180,7 @@ class ProxyAutomation(TerraformAutomation):
|
|||
$geoip2_metadata_country_build metadata build_epoch;
|
||||
$geoip2_data_country_code default=US country iso_code;
|
||||
}
|
||||
""" + self.sp_trusted_prefixes() + """
|
||||
""" + sp_trusted_prefixes() + """
|
||||
geoip2_proxy_recursive on;
|
||||
map $geoip2_data_country_code $redirect_country {
|
||||
default yes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue