import json from typing import List from app import app from app.lists.mirror_mapping import mirror_mapping from app.lists.bc2 import mirror_sites from app.lists.bridgelines import bridgelines from app.models.base import MirrorList from app.terraform.terraform import TerraformAutomation class ListAutomation(TerraformAutomation): template: str """ Terraform configuration template using Jinja 2. """ template_parameters: List[str] """ List of parameters to be read from the application configuration for use in the templating of the Terraform configuration. """ def tf_generate(self) -> None: self.tf_write( self.template, lists=MirrorList.query.filter( MirrorList.destroyed == None, MirrorList.provider == self.provider, ).all(), global_namespace=app.config['GLOBAL_NAMESPACE'], **{ k: app.config[k.upper()] for k in self.template_parameters } ) with open(self.working_directory('bc2.json'), 'w') as out: json.dump(mirror_sites(), out, indent=2, sort_keys=True) with open(self.working_directory('bca.json'), 'w') as out: json.dump(mirror_mapping(), out, indent=2, sort_keys=True) with open(self.working_directory('bridgelines.json'), 'w') as out: json.dump(bridgelines(), out, indent=2, sort_keys=True)