@@ -24,8 +24,8 @@ $ pip install libterraform
2424
2525` TerraformCommand ` is used to invoke various Terraform commands.
2626
27- Now, support all commands (` plan ` , ` apply ` , ` destroy ` etc.), and return a ` CommandResult ` object.
28- The ` CommandResult ` object has the following properties:
27+ Now, support all commands (` plan ` , ` apply ` , ` destroy ` etc.), and return a ` CommandResult ` object. The ` CommandResult `
28+ object has the following properties:
2929
3030- ` retcode ` indicates the command return code. A value of 0 or 2 is normal, otherwise is abnormal.
3131- ` value ` represents command output. If ` json=True ` is specified when executing the command, the output will be loaded
@@ -40,11 +40,11 @@ To get Terraform verison:
4040>> > TerraformCommand().version()
4141< CommandResult retcode= 0 json= True >
4242>> > _.value
43- {' terraform_version' : ' 1.1.7 ' , ' platform' : ' darwin_arm64' , ' provider_selections' : {}, ' terraform_outdated' : False }
43+ {' terraform_version' : ' 1.2.2 ' , ' platform' : ' darwin_arm64' , ' provider_selections' : {}, ' terraform_outdated' : False }
4444>> > TerraformCommand().version(json = False )
4545< CommandResult retcode= 0 json= False >
4646>> > _.value
47- ' Terraform v1.1.7 \n on darwin_arm64\n '
47+ ' Terraform v1.2.2 \n on darwin_arm64\n '
4848```
4949
5050To ` init ` and ` apply ` according to Terraform configuration files in the specified directory:
@@ -62,7 +62,7 @@ Additionally, `run()` can execute arbitrary commands, returning a tuple `(retcod
6262
6363``` python
6464>> > TerraformCommand.run(' version' )
65- (0 , ' Terraform v1.1.7 \n on darwin_arm64\n ' , ' ' )
65+ (0 , ' Terraform v1.2.2 \n on darwin_arm64\n ' , ' ' )
6666>> > TerraformCommand.run(' invalid' )
6767(1 , ' ' , ' Terraform has no command named "invalid".\n\n To see all of Terraform\' s top-level commands, run:\n terraform -help\n\n ' )
6868```
@@ -85,14 +85,23 @@ respectively.
8585dict_keys([' time_sleep.wait1' , ' time_sleep.wait2' ])
8686```
8787
88+ ## Version comparison
89+
90+ | libterraform | Terraform |
91+ | -------------------------------------------------------| -------------------------------------------------------------|
92+ | [ 0.4.0] ( https://pypi.org/project/libterraform/0.4.0/ ) | [ 1.2.2] ( https://github.com/hashicorp/terraform/tree/v1.2.2 ) |
93+ | [ 0.3.1] ( https://pypi.org/project/libterraform/0.3.1/ ) | [ 1.1.7] ( https://github.com/hashicorp/terraform/tree/v1.1.7 ) |
94+
8895## Building & Testing
8996
9097If you want to develop this library, should first prepare the following environments:
98+
9199- [ GoLang] ( https://go.dev/dl/ ) (Version 1.17.x or 1.16.x)
92100- [ Python] ( https://www.python.org/downloads/ ) (Version 3.6~ 3.10)
93101- GCC
94102
95103Then, initialize git submodule:
104+
96105``` bash
97106$ git submodule init
98107$ git submodule update
@@ -105,22 +114,23 @@ $ pip install poetry pytest
105114```
106115
107116Now, we can build and test:
117+
108118``` bash
109119$ poetry build -f wheel
110120$ pytest
111121```
112122
113-
114123## Why use this library?
115- Terraform is a great tool for deploying resources. If you need to call the Terraform command in the Python program
116- for deployment, a new process needs to be created to execute the Terraform command on the system. A typical example
117- of this is the [ python-terraform] ( https://github.com/beelit94/python-terraform ) library.
118- Doing so has the following problems:
124+
125+ Terraform is a great tool for deploying resources. If you need to call the Terraform command in the Python program for
126+ deployment, a new process needs to be created to execute the Terraform command on the system. A typical example of this
127+ is the [ python-terraform] ( https://github.com/beelit94/python-terraform ) library. Doing so has the following problems:
128+
119129- Requires Terraform commands on the system.
120130- The overhead of starting a new process is relatively high.
121131
122- This library compiles Terraform as a ** dynamic link library** in advance, and then loads it for calling.
123- So there is no need to install Terraform, nor to start a new process.
132+ This library compiles Terraform as a ** dynamic link library** in advance, and then loads it for calling. So there is no
133+ need to install Terraform, nor to start a new process.
124134
125- In addition, since the Terraform dynamic link library is loaded, this library can further call Terraform's
135+ In addition, since the Terraform dynamic link library is loaded, this library can further call Terraform's
126136** internal capabilities** , such as parsing Terraform config files.
0 commit comments