@@ -91,6 +91,8 @@ def parse_args(init_vars=None, tf_vars=None, targets=None, **kw):
91
91
))
92
92
if targets :
93
93
cmd_args += [("-target={}" .format (t )) for t in targets ]
94
+ if kw .get ('tf_var_file' ):
95
+ cmd_args .append ('-var-file={}' .format (kw ['tf_var_file' ]))
94
96
return cmd_args
95
97
96
98
@@ -309,11 +311,11 @@ def init(self, input=False, color=False, force_copy=False, plugin_dir=None,
309
311
init_vars = init_vars )
310
312
return self .execute_command ('init' , * cmd_args ).out
311
313
312
- def plan (self , input = False , color = False , refresh = True , tf_vars = None , targets = None , output = False ):
314
+ def plan (self , input = False , color = False , refresh = True , tf_vars = None , targets = None , output = False , tf_var_file = None ):
313
315
"Run Terraform plan command, optionally returning parsed plan output."
314
316
cmd_args = parse_args (input = input , color = color ,
315
317
refresh = refresh , tf_vars = tf_vars ,
316
- targets = targets )
318
+ targets = targets , tf_var_file = tf_var_file )
317
319
if not output :
318
320
return self .execute_command ('plan' , * cmd_args ).out
319
321
with tempfile .NamedTemporaryFile () as fp :
@@ -325,11 +327,11 @@ def plan(self, input=False, color=False, refresh=True, tf_vars=None, targets=Non
325
327
except json .JSONDecodeError as e :
326
328
raise TerraformTestError ('Error decoding plan output: {}' .format (e ))
327
329
328
- def apply (self , input = False , color = False , auto_approve = True , tf_vars = None , targets = None ):
330
+ def apply (self , input = False , color = False , auto_approve = True , tf_vars = None , targets = None , tf_var_file = None ):
329
331
"""Run Terraform apply command."""
330
332
cmd_args = parse_args (input = input , color = color ,
331
333
auto_approve = auto_approve , tf_vars = tf_vars ,
332
- targets = targets )
334
+ targets = targets , tf_var_file = tf_var_file )
333
335
return self .execute_command ('apply' , * cmd_args ).out
334
336
335
337
def output (self , name = None , color = False , json_format = True ):
@@ -347,10 +349,11 @@ def output(self, name=None, color=False, json_format=True):
347
349
_LOGGER .warning ('error decoding output: {}' .format (e ))
348
350
return output
349
351
350
- def destroy (self , color = False , auto_approve = True , tf_vars = None , targets = None ):
352
+ def destroy (self , color = False , auto_approve = True , tf_vars = None , targets = None , tf_var_file = None ):
351
353
"""Run Terraform destroy command."""
352
354
cmd_args = parse_args (color = color , auto_approve = auto_approve ,
353
- tf_vars = tf_vars , targets = targets )
355
+ tf_vars = tf_vars , targets = targets ,
356
+ tf_var_file = tf_var_file )
354
357
return self .execute_command ('destroy' , * cmd_args ).out
355
358
356
359
def refresh (self , color = False , lock = False , tf_vars = None , targets = None ):
0 commit comments