terraform-enterprise-cli 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7be0ff4722fee573ba06f5669c5ff3f06f83d865
4
- data.tar.gz: 54d126898d3df4a92ef5bfe6779cb8fe9d1de24f
3
+ metadata.gz: 4586f6d07044eea0e7a048333a0a42cdf7503ea6
4
+ data.tar.gz: e0d29b7c1ca286efb612ab63685be5a65c5e97eb
5
5
  SHA512:
6
- metadata.gz: a36b1e28eb77486f599d46ee4c7be11a362e71f9cfa2ba8c43f2d54aadd7527703adc2cacf8a6be7df894c8f2e1f6b5a1708ce992d88a27da70c105aa3ecf7b2
7
- data.tar.gz: 4f22023eb7fc584bbd3382916521378c037d89d462d10c302afa6066eca7a238e89e88fd949cfd41fa8a6b63f506a26fbb1876196b0b09f7355eeb6f38ae0419
6
+ metadata.gz: a29b53531da11eae5ad04ccbc39c1c57628b66368f8cb2bab04c1c6052d248bd111c6bb2f7e5741e6b2b7325ee86d994a82968e64448b3dad84b8c6fbc9e466b
7
+ data.tar.gz: 341d1972a76f5aa531a9857d585519777b6c52a2e061e5159c8fac2f449e9ebe9b8373d905e9c70854025a6e091d3dfdd81a6e7100a99dced1a5e263c27ff086
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Terraform Enterprise Command Line Tool
2
+
2
3
  A simple command line tool for the [Terraform Enterprise API](https://www.terraform.io/docs/enterprise/api/index.html).
3
4
 
4
5
  [![Gem Version](https://badge.fury.io/rb/terraform-enterprise-cli.svg)](https://badge.fury.io/rb/terraform-enterprise-cli)
@@ -31,7 +32,7 @@ All of the resources, actions and paraeters are documented in the tool and avail
31
32
 
32
33
  ### Basic Usage
33
34
 
34
- ```shell
35
+ ```bash
35
36
  ➭ tfe help
36
37
  Commands:
37
38
  tfe configuration-versions <subcommand> # Manage configuration versions
@@ -61,6 +62,15 @@ Options:
61
62
 
62
63
  There are two methods for authenticating the CLI with the Terraform Enterprise API. The first is to use the `TFE_TOKEN` environment variable. The second is to pass in the token on the command line using the `--token` option. The command line option takes precendence over the environment variable.
63
64
 
65
+ ## Using with Private Terraform Enterprise
66
+
67
+ The API for the hosted (SaaS) service at app.terraform.io is no different then private TFE. However, the host name must be updated to your private TFE instance. This can be done in one of two ways:
68
+
69
+ - Set the `TFE_HOST` environment variable to the hostname
70
+ - Set the hostname by passing in the `--host` option on the command line
71
+
72
+ **NOTE**: The hostname must also include the scheme (e.g. `https://`)
73
+
64
74
  ## Scripting
65
75
 
66
76
  The CLI is designed to be easy to call from other scripts. A few command line options exist to control the output format to minimize the string parsing needed to extract the desired data from the output:
@@ -107,22 +117,35 @@ The CLI supports managing the various Terraform Enterprise resources exposed via
107
117
 
108
118
  ### Upload a configuration-version
109
119
 
120
+ The configuration version is a resource in Terraform Enterprise which references the terraform configuration used in the run. The `configuration-version` resource must first be created, then a configuration must be uploaded. If you do not need such low-leve control, consider using the `tfe push` command instead.
121
+
110
122
  ```
111
- tfe configuration-versions upload
123
+ tfe configuration-versions upload <upload-url>
112
124
  ```
113
125
 
126
+ **Note**: Uploading a new configuration version will also start a new run. This is behavior is implemented by Terraform Enterprise, not the CLI or Client library.
127
+
128
+ The `upload-url` is provided in the `upload-url` attribute of the `configuration-version`. It is a very long and unique URL generated to use for uploading the configuration.
129
+
114
130
  ### Upload a Sentinel policy
115
131
 
132
+ In Terraform Enterprise the policy resource does not include the content of the policy file. The policy file is managed as another resource. As such, when creating a new policy, you must first create the policy then upload the content of the policy file. You can also upload a new policy file to an existing policy to update it.
133
+
116
134
  ```
117
- tfe policies upload
135
+ tfe policies upload <path> <policy_id>
118
136
  ```
119
137
 
138
+ The `path` should refence the `*.sentinel` file which contains the content of the policy.
139
+
120
140
  ### Override a policy check
121
141
 
142
+ If a policy fails and it's mode is set as `advisory` or `soft-mandatory` it can be overridden.
143
+
122
144
  ```
123
- tfe policy-checks override
145
+ tfe policy-checks override <policy-check-id>
124
146
  ```
125
147
 
148
+ To override the policy you will need the policy check ID. This ID is auto-generated by TFE when the policy check is executed after a successful plan. The Policy Checks can be listed using `tfe policy-checks list --run-id=<run-id>`. The Run ID can be obtained using `tfe runs list --workspace-id=<workspace-id>`.
126
149
 
127
150
  ### Apply or discard a run
128
151
 
@@ -168,6 +191,19 @@ A few command require the run ID. This can be obtained dusing the `tfe runs list
168
191
  tfe runs list --workspace-id=<workspace_id> --except status-timestamps permissions actions
169
192
  ```
170
193
 
194
+ ### Push a configuration
195
+
196
+ The `push` command is a convient command which mimics the functionality of the `terraform push` command which has been deprecated. This command performs a sequence of operations:
197
+
198
+ 1. Generates the tar.gz of the current directory (or the directory set using `--path` option)
199
+ 2. Given the organization and workspace name it looks up the workspace ID.
200
+ 3. Creates a new configuration-version resource in that workspace
201
+ 4. Uploads the configuration to the new configuration-version
202
+
203
+ ```
204
+ tfe push <org>/<workspace>
205
+ ```
206
+
171
207
  ## Contribution
172
208
 
173
209
  Contribution to the CLI is welcome. Opening issues and pull requests is welcome and will be reviewed.
@@ -179,6 +215,16 @@ To run the command line binary locally, use `bundle exec` to execute it with the
179
215
  ```
180
216
  bundle exec ./bin/tfe
181
217
  ```
218
+
219
+ ### Debugging
220
+
221
+ Operations internal to the CLI and API are instrumented to output additional debug logs if debugging is enabled. The logs will show the HTTP requests and responses.
222
+
223
+ Debugging can be enabled by:
224
+
225
+ - Setting the `TFE_DEBUG` environment variable to `true` by `export TFE_DEBUG=true`
226
+ - Passing in the `--debug` option on the command line.
227
+
182
228
  ### Command line design
183
229
 
184
230
  Basic design principles of the command line interface:
@@ -187,3 +233,7 @@ Basic design principles of the command line interface:
187
233
  - Required attributes should be set as parameters (e.g. `tfe workspaces create <name> <email>`
188
234
  - Optional attributes should be set as options
189
235
  - Relationships (member-of, belongs-to) on resources should be set as options (e.g. `tfe variables list --organization <org> --workspace <workspace>`
236
+
237
+ ### Opening Issues
238
+
239
+ When opening an issue, please include the version of the CLI you are using. The version can be obtained with the `tfe version` command.
@@ -1,4 +1,5 @@
1
1
  require 'terraform_enterprise/command_line/command'
2
+ require 'terraform_enterprise/command_line/version'
2
3
 
3
4
  require_relative 'configuration_versions'
4
5
  require_relative 'oauth_tokens'
@@ -77,7 +78,7 @@ module TerraformEnterprise
77
78
 
78
79
  desc 'version', STRINGS[:version][:commands][:version]
79
80
  def version
80
- puts "Terraform Enterprise CLI #{VERSION}"
81
+ puts "Terraform Enterprise CLI #{TerraformEnterprise::CommandLine::VERSION}"
81
82
  end
82
83
  end
83
84
  end
@@ -1,5 +1,5 @@
1
1
  module TerraformEnterprise
2
2
  module CommandLine
3
- VERSION = '0.0.9'.freeze
3
+ VERSION = '0.0.10'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform-enterprise-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Skierkowski