-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.php
72 lines (62 loc) · 1.28 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
use DivineOmega\HCLParser\HCLParser;
require __DIR__.'/vendor/autoload.php';
$hcl = '
# Specify the provider and access details
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
# Create an instance
resource "aws_instance" "example" {
ami = "ami-2757f631"
instance_type = "t2.micro"
}
';
$configObject = (new HCLParser($hcl))->parse();
var_dump($configObject);
/*
object(stdClass)#5 (2) {
["provider"]=>
array(1) {
[0]=>
object(stdClass)#4 (1) {
["aws"]=>
array(1) {
[0]=>
object(stdClass)#2 (3) {
["access_key"]=>
string(17) "${var.access_key}"
["region"]=>
string(13) "${var.region}"
["secret_key"]=>
string(17) "${var.secret_key}"
}
}
}
}
["resource"]=>
array(1) {
[0]=>
object(stdClass)#8 (1) {
["aws_instance"]=>
array(1) {
[0]=>
object(stdClass)#7 (1) {
["example"]=>
array(1) {
[0]=>
object(stdClass)#6 (2) {
["ami"]=>
string(12) "ami-2757f631"
["instance_type"]=>
string(8) "t2.micro"
}
}
}
}
}
}
}
*/