You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin is for wrapping shell scripts to make them fully fledged terraform resources. Note that this is a backdoor into the Terraform runtime. You can do some pretty dangerous things with this and it is up to you to make sure you don't get in trouble.
5
4
6
5
Since this provider is rather different than most other provider, it is recommended that you at least have some familiarity with the internals of Terraform before attempting to use this provider.
7
6
8
7
**Note:** many people use this provider for wrapping APIs of resources that are not supported by existing providers. For an example of using this provider to manage a Github repo resource, see `examples/github-repo`
To use this plugin, go to releases and download the binary for your specific OS and architecture. You can install the plugin by either putting it in your `~/.terraform/plugins` folder or in your terraform workspace by performing a `terraform init`.
33
-
34
9
## Configuring the Provider
35
10
The provider can be configured with optional `environment` and `sensitive_environment` attributes. If these are set, then they will be used to configure all resources which rely on them (without triggering a force new update!)
36
11
@@ -53,8 +28,9 @@ provider "shell" {
53
28
interpreter = ["/bin/bash", "-c"]
54
29
enable_parallelism = true
55
30
}
56
-
```
57
-
## Data Sources
31
+
Data Sources
32
+
------------
33
+
58
34
The simplest example is the data source which implements only Read(). Any output to stdout or stderr will show up in the logs, but to save state, you must output a JSON payload to stdout. The last JSON object printed to stdout will be taken to be the output state. The JSON can be a complex nested JSON, but will be flattened into a `map[string]string`. The reason for this is that your JSON payload variables can be accessed from the output map of this resource and used like a normal terraform output, so the value must be a string. You can use the built-in jsondecode() function to read nested JSON values if you really need to.
59
35
60
36
Below is an example of using the data source. The output of `whoami` is stored in a JSON object for the key `user`
@@ -116,7 +92,9 @@ Outputs:
116
92
weather = SanFrancisco: ⛅️ +54°F
117
93
```
118
94
119
-
## Resources
95
+
Resources
96
+
------------
97
+
120
98
Resources are a bit more complicated. At a minimum, you must implement the `CREATE`, and `DELETE` lifecycle commands. `READ` and `UPDATE` are optional arguments.
121
99
122
100
* If you choose not to implement the `READ` command, then `CREATE` (and `UPDATE` if you are using it) must output JSON. The local state will not be synced with the actual state, but for many applications that is not a problem.
@@ -192,10 +170,55 @@ export TF_LOG=1
192
170
```
193
171
**Note:** if you are using sensitive_environment to set sensitive environment variables, these values won't show up in the logs
1. Build the provider using the Go `install` command:
198
186
```sh
199
-
$ make test
187
+
$ go install
200
188
```
201
189
190
+
Adding Dependencies
191
+
---------------------
192
+
193
+
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
194
+
Please see the Go documentation for the most up to date information about using Go modules.
195
+
196
+
To add a new dependency `github.com/author/dependency` to your Terraform provider:
197
+
198
+
```
199
+
go get github.com/author/dependency
200
+
go mod tidy
201
+
```
202
+
203
+
Then commit the changes to `go.mod` and `go.sum`.
204
+
205
+
206
+
Using the provider
207
+
----------------------
208
+
209
+
Fill this in for each provider
210
+
211
+
Developing the Provider
212
+
---------------------------
213
+
214
+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
215
+
216
+
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
217
+
218
+
In order to run the full suite of Acceptance tests, run `make testacc`.
219
+
220
+
*Note:* Acceptance tests create real resources, and often cost money to run.
0 commit comments