Class: Terracop::StateLoader
- Inherits:
-
Object
- Object
- Terracop::StateLoader
- Defined in:
- lib/terracop/state_loader.rb
Overview
Loads a Terraform state file and transforms it into a Terracop-friendly list of instances.
Class Method Summary collapse
Class Method Details
.load(file) ⇒ Object
8 9 10 11 |
# File 'lib/terracop/state_loader.rb', line 8 def load(file) state = File.read(file) load_from_text(state) end |
.load_from_text(text) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/terracop/state_loader.rb', line 13 def load_from_text(text) state = JSON.parse(text) managed_resources = state['resources'].select do |resource| resource['mode'] == 'managed' end flatten_instances(managed_resources) end |