fix backend config
This commit is contained in:
parent
d3eac3e986
commit
50ac1e93e2
2 changed files with 32 additions and 8 deletions
src/main
python/ddadevops
resources/terraform
|
@ -2,9 +2,18 @@ from dda_python_terraform import *
|
||||||
from .digitalocean_terraform_build import DigitaloceanTerraformBuild
|
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':
|
config.update({'DigitaloceanBackendPropertiesMixin':
|
||||||
{'account_name': account_name}})
|
{'account_name': account_name,
|
||||||
|
'endpoint': endpoint,
|
||||||
|
'bucket': bucket,
|
||||||
|
'key': key,
|
||||||
|
'region': region}})
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,14 +21,28 @@ class DigitaloceanBackendPropertiesMixin(DigitaloceanTerraformBuild):
|
||||||
|
|
||||||
def __init__(self, project, config):
|
def __init__(self, project, config):
|
||||||
super().__init__(project, config)
|
super().__init__(project, config)
|
||||||
aws_mixin_config = config['DigitaloceanBackendPropertiesMixin']
|
do_mixin_config = config['DigitaloceanBackendPropertiesMixin']
|
||||||
self.account_name = aws_mixin_config['account_name']
|
self.account_name = do_mixin_config['account_name']
|
||||||
self.backend_config = "backend." + self.account_name + "." + self.stage + ".properties"
|
self.endpoint = do_mixin_config['endpoint']
|
||||||
self.additional_tfvar_files.append(self.backend_config)
|
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):
|
def project_vars(self):
|
||||||
ret = super().project_vars()
|
ret = super().project_vars()
|
||||||
ret.update({'account_name': self.account_name})
|
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
|
return ret
|
||||||
|
|
||||||
def copy_build_resources_from_package(self):
|
def copy_build_resources_from_package(self):
|
||||||
|
@ -36,7 +59,8 @@ class DigitaloceanBackendPropertiesMixin(DigitaloceanTerraformBuild):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def init_client(self):
|
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)
|
tf.init(backend_config=self.backend_config)
|
||||||
self.print_terraform_command(tf)
|
self.print_terraform_command(tf)
|
||||||
if self.use_workspace:
|
if self.use_workspace:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
variable "endpoint" {}
|
||||||
variable "bucket" {}
|
variable "bucket" {}
|
||||||
variable "key" {}
|
variable "key" {}
|
||||||
variable "kms_key_id" {}
|
|
||||||
variable "region" {}
|
variable "region" {}
|
||||||
variable "account_name" {}
|
variable "account_name" {}
|
Loading…
Add table
Reference in a new issue