|
1 | 1 | ---
|
2 |
| -page_title: "restapi Provider" |
3 |
| -subcategory: "" |
| 2 | +page_title: restapi Provider |
| 3 | +subcategory: "Utility" |
4 | 4 | description: |-
|
5 |
| - |
| 5 | + Ultra-thin REST wrapper for the OpenZiti Management API forked from Mastercard/restapi |
6 | 6 | ---
|
7 | 7 |
|
8 | 8 | # restapi Provider
|
9 | 9 |
|
| 10 | +## A Note about Terraform Provider Configuration |
10 | 11 |
|
| 12 | +You'll probably need to get the provider configuration from remote state provided by another plan. This is because provider configuration occurs in an early phase of plan and apply, and so it's not possible to reliably obtain the configuration values from the same plan. |
11 | 13 |
|
| 14 | +## Example Usage |
12 | 15 |
|
| 16 | +```terraform |
| 17 | +terraform { |
| 18 | + cloud {} |
| 19 | + required_providers { |
| 20 | + restapi = { |
| 21 | + source = "qrkourier/restapi" |
| 22 | + version = "~> 1.23.0" |
| 23 | + } |
| 24 | + } |
| 25 | +} |
13 | 26 |
|
| 27 | +data "terraform_remote_state" "controller_state" { |
| 28 | + backend = "remote" |
| 29 | + config = { |
| 30 | + organization = "acmeorg" |
| 31 | + workspaces = { |
| 32 | + name = "acmespace" |
| 33 | + } |
| 34 | + } |
| 35 | +} |
| 36 | +
|
| 37 | +provider restapi { |
| 38 | + uri = "https://${data.terraform_remote_state.controller_state.outputs.ziti_controller_mgmt_external_host}:443/edge/management/v1" |
| 39 | + cacerts_string = (data.terraform_remote_state.controller_state.outputs.ctrl_plane_cas).data["ctrl-plane-cas.crt"] |
| 40 | + ziti_username = (data.terraform_remote_state.controller_state.outputs.ziti_admin_password).data["admin-user"] |
| 41 | + ziti_password = (data.terraform_remote_state.controller_state.outputs.ziti_admin_password).data["admin-password"] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +## OpenZiti Authentication |
| 46 | + |
| 47 | +You must provide at least one of `cacerts_file` or `cacerts_string` with the OpenZiti Controller's CA bundle as PEM. |
| 48 | + |
| 49 | +You must provide at least one of (`ziti_username` and `ziti_password`) or ((`cert_file` or `cert_string`) and (`key_file` or `key_string`)). |
| 50 | + |
| 51 | +You must have an `updb` Authenticator to use password auth. |
| 52 | + |
| 53 | +You must have a `cert` Authenticator and compatible Authentication Policy to use cert auth. |
| 54 | + |
| 55 | +<!-- schema generated by tfplugindocs --> |
14 | 56 | ## Schema
|
15 | 57 |
|
16 | 58 | ### Required
|
17 | 59 |
|
18 |
| -- **uri** (String, Required) URI of the REST API endpoint. This serves as the base of all requests. |
| 60 | +- `uri` (String) URI of the REST API endpoint. This serves as the base of all requests. |
19 | 61 |
|
20 | 62 | ### Optional
|
21 | 63 |
|
22 |
| -- **cert_file** (String, Optional) When set with the key_file parameter, the provider will load a client certificate as a file for mTLS authentication. |
23 |
| -- **cert_string** (String, Optional) When set with the key_string parameter, the provider will load a client certificate as a string for mTLS authentication. |
24 |
| -- **copy_keys** (List of String, Optional) When set, any PUT to the API for an object will copy these keys from the data the provider has gathered about the object. This is useful if internal API information must also be provided with updates, such as the revision of the object. |
25 |
| -- **create_method** (String, Optional) Defaults to `POST`. The HTTP method used to CREATE objects of this type on the API server. |
26 |
| -- **create_returns_object** (Boolean, Optional) Set this when the API returns the object created only on creation operations (POST). This is used by the provider to refresh internal data structures. |
27 |
| -- **debug** (Boolean, Optional) Enabling this will cause lots of debug information to be printed to STDOUT by the API client. |
28 |
| -- **destroy_method** (String, Optional) Defaults to `DELETE`. The HTTP method used to DELETE objects of this type on the API server. |
29 |
| -- **headers** (Map of String, Optional) A map of header names and values to set on all outbound requests. This is useful if you want to use a script via the 'external' provider or provide a pre-approved token or change Content-Type from `application/json`. If `username` and `password` are set and Authorization is one of the headers defined here, the BASIC auth credentials take precedence. |
30 |
| -- **id_attribute** (String, Optional) When set, this key will be used to operate on REST objects. For example, if the ID is set to 'name', changes to the API object will be to http://foo.com/bar/VALUE_OF_NAME. This value may also be a '/'-delimited path to the id attribute if it is multiple levels deep in the data (such as `attributes/id` in the case of an object `{ "attributes": { "id": 1234 }, "config": { "name": "foo", "something": "bar"}}` |
31 |
| -- **insecure** (Boolean, Optional) When using https, this disables TLS verification of the host. |
32 |
| -- **key_file** (String, Optional) When set with the cert_file parameter, the provider will load a client certificate as a file for mTLS authentication. Note that this mechanism simply delegates to golang's tls.LoadX509KeyPair which does not support passphrase protected private keys. The most robust security protections available to the key_file are simple file system permissions. |
33 |
| -- **key_string** (String, Optional) When set with the cert_string parameter, the provider will load a client certificate as a string for mTLS authentication. Note that this mechanism simply delegates to golang's tls.LoadX509KeyPair which does not support passphrase protected private keys. The most robust security protections available to the key_file are simple file system permissions. |
34 |
| -- **oauth_client_credentials** (Block List, Max: 1) Configuration for oauth client credential flow (see [below for nested schema](#nestedblock--oauth_client_credentials)) |
35 |
| -- **password** (String, Optional) When set, will use this password for BASIC auth to the API. |
36 |
| -- **rate_limit** (Number, Optional) Set this to limit the number of requests per second made to the API. |
37 |
| -- **read_method** (String, Optional) Defaults to `GET`. The HTTP method used to READ objects of this type on the API server. |
38 |
| -- **test_path** (String, Optional) If set, the provider will issue a read_method request to this path after instantiation requiring a 200 OK response before proceeding. This is useful if your API provides a no-op endpoint that can signal if this provider is configured correctly. Response data will be ignored. |
39 |
| -- **timeout** (Number, Optional) When set, will cause requests taking longer than this time (in seconds) to be aborted. |
40 |
| -- **update_method** (String, Optional) Defaults to `PUT`. The HTTP method used to UPDATE objects of this type on the API server. |
41 |
| -- **use_cookies** (Boolean, Optional) Enable cookie jar to persist session. |
42 |
| -- **username** (String, Optional) When set, will use this username for BASIC auth to the API. |
43 |
| -- **write_returns_object** (Boolean, Optional) Set this when the API returns the object created on all write operations (POST, PUT). This is used by the provider to refresh internal data structures. |
44 |
| -- **xssi_prefix** (String, Optional) Trim the xssi prefix from response string, if present, before parsing. |
| 64 | +- `cacerts_file` (String) One or more CA certs to trust as a PEM bundle in a file. |
| 65 | +- `cacerts_string` (String) One or more CA certs to trust as a PEM bundle in a string. |
| 66 | +- `cert_file` (String) When set with the key_file parameter, the provider will load a client certificate as a file for mTLS authentication. |
| 67 | +- `cert_string` (String) When set with the key_string parameter, the provider will load a client certificate as a string for mTLS authentication. |
| 68 | +- `copy_keys` (List of String) When set, any PUT to the API for an object will copy these keys from the data the provider has gathered about the object. This is useful if internal API information must also be provided with updates, such as the revision of the object. |
| 69 | +- `create_method` (String) Defaults to `POST`. The HTTP method used to CREATE objects of this type on the API server. |
| 70 | +- `create_returns_object` (Boolean) Set this when the API returns the object created only on creation operations (POST). This is used by the provider to refresh internal data structures. |
| 71 | +- `debug` (Boolean) Enabling this will cause lots of debug information to be printed to STDOUT by the API client. |
| 72 | +- `destroy_method` (String) Defaults to `DELETE`. The HTTP method used to DELETE objects of this type on the API server. |
| 73 | +- `headers` (Map of String) A map of header names and values to set on all outbound requests. This is useful if you want to use a script via the 'external' provider or provide a pre-approved token or change Content-Type from `application/json`. If `username` and `password` are set and Authorization is one of the headers defined here, the BASIC auth credentials take precedence. |
| 74 | +- `id_attribute` (String) When set, this key will be used to operate on REST objects. For example, if the ID is set to 'name', changes to the API object will be to http://foo.com/bar/VALUE_OF_NAME. This value may also be a '/'-delimeted path to the id attribute if it is multple levels deep in the data (such as `attributes/id` in the case of an object `{ "attributes": { "id": 1234 }, "config": { "name": "foo", "something": "bar"}}` |
| 75 | +- `insecure` (Boolean) When using https, this disables TLS verification of the host. |
| 76 | +- `key_file` (String) When set with the cert_file parameter, the provider will load a client certificate as a file for mTLS authentication. Note that this mechanism simply delegates to golang's tls.LoadX509KeyPair which does not support passphrase protected private keys. The most robust security protections available to the key_file are simple file system permissions. |
| 77 | +- `key_string` (String) When set with the cert_string parameter, the provider will load a client certificate as a string for mTLS authentication. Note that this mechanism simply delegates to golang's tls.LoadX509KeyPair which does not support passphrase protected private keys. The most robust security protections available to the key_file are simple file system permissions. |
| 78 | +- `oauth_client_credentials` (Block List, Max: 1) Configuration for oauth client credential flow (see [below for nested schema](#nestedblock--oauth_client_credentials)) |
| 79 | +- `password` (String) When set, will use this password for BASIC auth to the API. |
| 80 | +- `rate_limit` (Number) Set this to limit the number of requests per second made to the API. |
| 81 | +- `read_method` (String) Defaults to `GET`. The HTTP method used to READ objects of this type on the API server. |
| 82 | +- `test_path` (String) If set, the provider will issue a read_method request to this path after instantiation requiring a 200 OK response before proceeding. This is useful if your API provides a no-op endpoint that can signal if this provider is configured correctly. Response data will be ignored. |
| 83 | +- `timeout` (Number) When set, will cause requests taking longer than this time (in seconds) to be aborted. |
| 84 | +- `update_method` (String) Defaults to `PUT`. The HTTP method used to UPDATE objects of this type on the API server. |
| 85 | +- `use_cookies` (Boolean) Enable cookie jar to persist session. |
| 86 | +- `username` (String) When set, will use this username for BASIC auth to the API. |
| 87 | +- `write_returns_object` (Boolean) Set this when the API returns the object created on all write operations (POST, PUT). This is used by the provider to refresh internal data structures. |
| 88 | +- `xssi_prefix` (String) Trim the xssi prefix from response string, if present, before parsing. |
| 89 | +- `ziti_password` (String) When set, will use this password for Ziti auth to the API. |
| 90 | +- `ziti_username` (String) When set, will use this username for Ziti auth to the API. |
45 | 91 |
|
46 | 92 | <a id="nestedblock--oauth_client_credentials"></a>
|
47 | 93 | ### Nested Schema for `oauth_client_credentials`
|
48 | 94 |
|
49 | 95 | Required:
|
50 | 96 |
|
51 |
| -- **oauth_client_id** (String, Required) client id |
52 |
| -- **oauth_client_secret** (String, Required) client secret |
53 |
| -- **oauth_token_endpoint** (String, Required) oauth token endpoint |
| 97 | +- `oauth_client_id` (String) client id |
| 98 | +- `oauth_client_secret` (String) client secret |
| 99 | +- `oauth_token_endpoint` (String) oauth token endpoint |
54 | 100 |
|
55 | 101 | Optional:
|
56 | 102 |
|
57 |
| -- **endpoint_params** (Map of List of String, Optional) Additional key/values to pass to the underlying Oauth client library (as EndpointParams) |
58 |
| -- **oauth_scopes** (List of String, Optional) scopes |
| 103 | +- `endpoint_params` (Map of List of String) Additional key/values to pass to the underlying Oauth client library (as EndpointParams) |
| 104 | +- `oauth_scopes` (List of String) scopes |
0 commit comments