PHP code example of skluck / terraform-plan-parser
1. Go to this page and download the library: Download skluck/terraform-plan-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skluck / terraform-plan-parser example snippets
use SK\TerraformParser\TerraformOutputParser;
use SK\TerraformParser\Terraform11OutputParser;
use SK\TerraformParser\Terraform12OutputParser;
$filename = '/path/to/terrraform/output';
$parser = new TerraformOutputParser;
// It is also possible to use the desired version of Terraform directly:
// $parser = new Terraform11OutputParser;
// $parser = new Terraform12OutputParser;
$output = $parser->parseFile($filename);
var_export($output);
// [
// 'errors' => [
// 'Failed to parse resource name (line 63)',
// 'Failed to parse attribute name (line 102)',
// 'Failed to parse attribute name (line 103)',
// ],
// 'changedResources' => [
// ResourceChange,
// ResourceChange,
// ResourceChange,
// ],
// "modules": [
// {
// "name": "module.mymodule",
// "source": "./path/to/submodule",
// "version": null
// },
// {
// "name": "root",
// "source": "git::https://git.example.com/terraform/mymodule2.git",
// "version": "2.3.1"
// }
// ]
// ];