lint: reformat python code with black
This commit is contained in:
parent
331beb01b4
commit
a406a7974b
88 changed files with 2579 additions and 1608 deletions
|
@ -17,7 +17,7 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
|
|||
"admin_email",
|
||||
"aws_access_key",
|
||||
"aws_secret_key",
|
||||
"smart_zone"
|
||||
"smart_zone",
|
||||
]
|
||||
|
||||
template = """
|
||||
|
@ -111,26 +111,35 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
|
|||
def import_state(self, state: Any) -> None:
|
||||
if not isinstance(state, dict):
|
||||
raise RuntimeError("The Terraform state object returned was not a dict.")
|
||||
if "child_modules" not in state['values']['root_module']:
|
||||
if "child_modules" not in state["values"]["root_module"]:
|
||||
# There are no CloudFront proxies deployed to import state for
|
||||
return
|
||||
# CloudFront distributions (proxies)
|
||||
for mod in state['values']['root_module']['child_modules']:
|
||||
if mod['address'].startswith('module.cloudfront_'):
|
||||
for res in mod['resources']:
|
||||
if res['address'].endswith('aws_cloudfront_distribution.this'):
|
||||
proxy = Proxy.query.filter(Proxy.id == mod['address'][len('module.cloudfront_'):]).first()
|
||||
proxy.url = "https://" + res['values']['domain_name']
|
||||
proxy.slug = res['values']['id']
|
||||
for mod in state["values"]["root_module"]["child_modules"]:
|
||||
if mod["address"].startswith("module.cloudfront_"):
|
||||
for res in mod["resources"]:
|
||||
if res["address"].endswith("aws_cloudfront_distribution.this"):
|
||||
proxy = Proxy.query.filter(
|
||||
Proxy.id == mod["address"][len("module.cloudfront_") :]
|
||||
).first()
|
||||
proxy.url = "https://" + res["values"]["domain_name"]
|
||||
proxy.slug = res["values"]["id"]
|
||||
proxy.terraform_updated = datetime.now(tz=timezone.utc)
|
||||
break
|
||||
# EC2 instances (smart proxies)
|
||||
for g in state["values"]["root_module"]["child_modules"]:
|
||||
if g["address"].startswith("module.smart_proxy_"):
|
||||
group_id = int(g["address"][len("module.smart_proxy_"):])
|
||||
group_id = int(g["address"][len("module.smart_proxy_") :])
|
||||
for s in g["child_modules"]:
|
||||
if s["address"].endswith(".module.instance"):
|
||||
for x in s["resources"]:
|
||||
if x["address"].endswith(".module.instance.aws_instance.default[0]"):
|
||||
update_smart_proxy_instance(group_id, self.provider, "us-east-2a", x['values']['id'])
|
||||
if x["address"].endswith(
|
||||
".module.instance.aws_instance.default[0]"
|
||||
):
|
||||
update_smart_proxy_instance(
|
||||
group_id,
|
||||
self.provider,
|
||||
"us-east-2a",
|
||||
x["values"]["id"],
|
||||
)
|
||||
db.session.commit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue