diff --git a/python_terraform/terraform.py b/python_terraform/terraform.py index aa7ef46..b5aae6c 100644 --- a/python_terraform/terraform.py +++ b/python_terraform/terraform.py @@ -338,7 +338,7 @@ class Terraform: return ret_code, out, err def output( - self, *args, capture_output: bool = True, **kwargs + self, dir_or_plan: Optional[str] = None, *args, capture_output: bool = True, **kwargs ) -> Union[None, str, Dict[str, str], Dict[str, Dict[str, str]]]: """Refer https://www.terraform.io/docs/commands/output.html @@ -366,8 +366,10 @@ class Terraform: if capture_output is False: raise ValueError("capture_output is required for this method") - global_opts = self._generate_default_general_options(False) - ret, out, _ = self.output_cmd(global_opts, *args, **kwargs) + global_opts = self._generate_default_general_options(dir_or_plan) + ret, out, _ = self.cmd(global_opts, "output", *args, **kwargs) + + # ret, out, _ = self.output_cmd(global_opts, *args, **kwargs) if ret: return None diff --git a/test/test_terraform.py b/test/test_terraform.py index 91f5bc4..275201b 100644 --- a/test/test_terraform.py +++ b/test/test_terraform.py @@ -408,7 +408,7 @@ class TestTerraform: tf.init("var_to_output") tf.apply("var_to_output") params = tuple() if output_all else (required_output,) - result = tf.output(*params) + result = tf.output("var_to_output", *params) if output_all: assert result[required_output]["value"] == expected_value else: