terraform: generate conf with http backend

This commit is contained in:
Iain Learmonth 2022-08-30 10:05:12 +01:00
parent affa0f0149
commit 32239c379a
16 changed files with 43 additions and 4 deletions

View file

@ -1,4 +1,5 @@
import datetime
import os
from typing import Any
from app import app
@ -39,6 +40,7 @@ class EotkAWSAutomation(TerraformAutomation):
template = """
terraform {
{{ backend_config }}
required_providers {
aws = {
version = "~> 4.4.0"
@ -84,6 +86,12 @@ class EotkAWSAutomation(TerraformAutomation):
Group.destroyed.is_(None)
).all(),
global_namespace=app.config['GLOBAL_NAMESPACE'],
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