#terraform #state #serde #parser

terraform-parser

Strictly typed terraform plan and state files parser written in Rust

1 unstable release

0.1.0 Apr 8, 2022

#2264 in Encoding

MIT license

9KB
198 lines

terraform-parser

Incredibly fast, strictly typed terraform files parser written in Rust. Based on serde.

Usage

use std::fs;
use terraform_parser::TerraformParser;

fn main() {
  let state =
    fs::read_to_string("./state.json").expect("Something went wrong reading the state file");

  let plan =
    fs::read_to_string("./plan.json").expect("Something went wrong reading the plan file");

  let parsed_state = TerraformParser::parse_state(&state);
  let parsed_plan = TerraformParser::parse_plan(&plan);

  println!("{}", parsed_state.unwrap().terraform_version);
  println!("{}", parsed_plan.unwrap().format_version);
}

Dependencies

~0.7–1.6MB
~34K SLoC