Parse terraform show -json output and extract resources (terraform 1.3+)
(&self, json_output: &str)
| 92 | |
| 93 | /// Parse terraform show -json output and extract resources (terraform 1.3+) |
| 94 | pub fn parse(&self, json_output: &str) -> Result<Vec<TerraformResource>, String> { |
| 95 | // Deserialize to infrastructure DTO |
| 96 | let output: TerraformShowOutput = |
| 97 | serde_json::from_str(json_output).map_err(|e| format!("Failed to parse JSON: {}", e))?; |
| 98 | |
| 99 | // Extract resources from root module (and recursively from child modules) |
| 100 | Ok(self.extract_from_module(&output.values.root_module)) |
| 101 | } |
| 102 | |
| 103 | /// Extract resources from a module and its child modules (recursive) |
| 104 | fn extract_from_module(&self, module: &TerraformModule) -> Vec<TerraformResource> { |