fix backend config

This commit is contained in:
jerger 2022-12-10 17:11:31 +01:00
parent d3eac3e986
commit 50ac1e93e2
2 changed files with 32 additions and 8 deletions

View file

@ -2,9 +2,18 @@ from dda_python_terraform import *
from .digitalocean_terraform_build import DigitaloceanTerraformBuild
def add_digitalocean_backend_properties_mixin_config(config, account_name):
def add_digitalocean_backend_properties_mixin_config(config,
account_name,
endpoint,
bucket,
key,
region='eu-central-1'):
config.update({'DigitaloceanBackendPropertiesMixin':
{'account_name': account_name}})
{'account_name': account_name,
'endpoint': endpoint,
'bucket': bucket,
'key': key,
'region': region}})
return config
@ -12,14 +21,28 @@ class DigitaloceanBackendPropertiesMixin(DigitaloceanTerraformBuild):
def __init__(self, project, config):
super().__init__(project, config)
aws_mixin_config = config['DigitaloceanBackendPropertiesMixin']
self.account_name = aws_mixin_config['account_name']
self.backend_config = "backend." + self.account_name + "." + self.stage + ".properties"
self.additional_tfvar_files.append(self.backend_config)
do_mixin_config = config['DigitaloceanBackendPropertiesMixin']
self.account_name = do_mixin_config['account_name']
self.endpoint = do_mixin_config['endpoint']
self.bucket = do_mixin_config['bucket']
self.key = do_mixin_config['account_name'] + \
'/' + do_mixin_config['key']
self.region = do_mixin_config['region']
self.backend_config = {
'access_key': self.do_spaces_access_id,
'secret_key': self.do_spaces_secret_key,
'endpoint': self.endpoint,
'bucket': self.bucket,
'key': self.key,
'region': self.region}
def project_vars(self):
ret = super().project_vars()
ret.update({'account_name': self.account_name})
ret.update({'endpoint': self.endpoint})
ret.update({'bucket': self.bucket})
ret.update({'key': self.key})
ret.update({'region': self.region})
return ret
def copy_build_resources_from_package(self):
@ -36,7 +59,8 @@ class DigitaloceanBackendPropertiesMixin(DigitaloceanTerraformBuild):
pass
def init_client(self):
tf = Terraform(working_dir=self.build_path(), terraform_semantic_version=self.terraform_semantic_version)
tf = Terraform(working_dir=self.build_path(),
terraform_semantic_version=self.terraform_semantic_version)
tf.init(backend_config=self.backend_config)
self.print_terraform_command(tf)
if self.use_workspace:

View file

@ -1,5 +1,5 @@
variable "endpoint" {}
variable "bucket" {}
variable "key" {}
variable "kms_key_id" {}
variable "region" {}
variable "account_name" {}