aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/terraform_state.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/terraform_state.rb b/app/models/terraform_state.rb
index 2ea7c91..f047137 100644
--- a/app/models/terraform_state.rb
+++ b/app/models/terraform_state.rb
@@ -30,4 +30,17 @@
#
class TerraformState < ApplicationRecord
+ def data_for_module(path)
+ data['modules'].find { |x| x['path'] == path }
+ end
+
+ def outputs(module_path: ['root'])
+ data_for_module(module_path)['outputs']
+ end
+
+ def output_value(name, module_path: ['root'])
+ output = outputs(module_path: module_path)[name]
+
+ output['value'] if output
+ end
end