Skip to content

Commit

Permalink
edb-terraform cli - infra_variables option added to pass in a yaml/js…
Browse files Browse the repository at this point in the history
…on file or input for use with a infrastructure template file.
  • Loading branch information
bryan-bar committed Jan 16, 2024
1 parent f38a40e commit 1388d45
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
43 changes: 28 additions & 15 deletions edbterraform/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from edbterraform.lib import generate_terraform
from edbterraform.CLI import TerraformCLI
from edbterraform import __project_name__, __dot_project__, __version__
from edbterraform.utils import logs
from edbterraform.utils import logs, files

ENVIRONMENT_PREFIX = 'ET_' # Appended to allow overrides of defaults

Expand Down Expand Up @@ -130,6 +130,16 @@ def __getitem__(self, key):
help="cloud service provider infrastructure file path (YAML format). Default: %(default)s"
)

InfrastructureVariables = ArgumentConfig(
names = ['--infra-variables',],
metavar='INFRA_VARIABLES',
dest='infra_variables',
default='{}',
type=files.load_yaml_file,
required=False,
help="Infrastructure variables file path or a string representing yaml or json. Default: %(default)s"
)

TerraformLockHcl = ArgumentConfig(
names = ['--lock-hcl-file',],
metavar='LOCK_HCL_FILE',
Expand Down Expand Up @@ -277,6 +287,7 @@ class Arguments:
'generate': ['Generate terraform files based on a yaml infrastructure file\n',[
ProjectName,
InfrastructureFilePath,
InfrastructureVariables,
WorkPath,
CloudServiceProvider,
Validation,
Expand Down Expand Up @@ -374,24 +385,26 @@ def process_args(self):
)
if self.command == 'depreciated':
outputs = generate_terraform(
self.get_env('infra_file'),
self.get_env('project_path'),
self.get_env('csp'),
self.get_env('bin_path'),
self.get_env('run_validation'),
infra_file=self.get_env('infra_file'),
project_path=self.get_env('project_path'),
csp=self.get_env('csp'),
bin_path=self.get_env('bin_path'),
run_validation=self.get_env('run_validation'),
)
return outputs

if self.command == 'generate':
outputs = generate_terraform(
self.get_env('infra_file'),
self.get_env('work_path') / self.get_env('project_name'),
self.get_env('csp'),
self.get_env('bin_path'),
self.get_env('user_templates'),
self.get_env('lock_hcl_file'),
self.get_env('run_validation'),
self.get_env('apply'),
self.get_env('destroy'),
infra_file=self.get_env('infra_file'),
infra_variables=self.get_env('infra_variables'),
project_path=self.get_env('work_path') / self.get_env('project_name'),
csp=self.get_env('csp'),
bin_path=self.get_env('bin_path'),
user_templates=self.get_env('user_templates'),
hcl_lock_file=self.get_env('lock_hcl_file'),
run_validation=self.get_env('run_validation'),
apply=self.get_env('apply'),
destroy=self.get_env('destroy'),
)
return outputs

Expand Down
1 change: 1 addition & 0 deletions edbterraform/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def build_vars(csp: str, infra_vars: Path, server_output_name: str):

def generate_terraform(
infra_file: Path,
infra_variables: dict,
project_path: Path,
csp: str,
bin_path: Path,
Expand Down

0 comments on commit 1388d45

Please sign in to comment.