Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendrucker/terraform-cloud-cli
Interactive CLI for operating workspaces in Terraform Cloud
https://github.com/bendrucker/terraform-cloud-cli
cli golang terraform terraform-cloud
Last synced: 22 days ago
JSON representation
Interactive CLI for operating workspaces in Terraform Cloud
- Host: GitHub
- URL: https://github.com/bendrucker/terraform-cloud-cli
- Owner: bendrucker
- License: mit
- Created: 2020-05-09T03:47:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-20T16:55:11.000Z (over 2 years ago)
- Last Synced: 2024-06-20T00:33:04.951Z (5 months ago)
- Topics: cli, golang, terraform, terraform-cloud
- Language: Go
- Homepage:
- Size: 407 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# terraform-cloud-cli [![tests](https://github.com/bendrucker/terraform-cloud-cli/workflows/tests/badge.svg?branch=master)](https://github.com/bendrucker/terraform-cloud-cli/actions?query=workflow%3Atests) [![Project Status: WIP](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
> Interactive CLI for operating workspaces in Terraform Cloud
`terraform-cloud` is an interactive CLI that helps automate complex and repetitive tasks in [Terraform Cloud](https://www.terraform.io/docs/cloud/index.html). It is designed to compliment the [Terraform Enterprise Provider](https://www.terraform.io/docs/providers/tfe/index.html). The `tfe` provider can manage teams, workspaces, variables, and other Terraform Cloud resources. This CLI is not focused on being a complete API client.
**Status**: Early development. You will likely encounter bugs. Breaking changes will bump the `0.x` version until version `1.0.0`.
## Installing
Binaries are available for each [tagged release](https://github.com/bendrucker/terraform-cloud-cli/releases). Download an appropriate binary for your operating system and install it into `$PATH`.
You can also install with Homebrew:
```sh
brew tap bendrucker/terraform-cloud-cli
brew install terraform-cloud-cli
```## Usage
```
Usage: terraform-cloud [--version] [--help] []Available commands are:
migrate Migrate a Terraform module from an existing backend to Terraform Cloud
open Opens the Terraform Cloud UI to the workspace
```
### `migrate`
```
Usage: terraform-cloud migrate [options]
Migrate a Terraform module from an existing backend to Terraform CloudOptions:
--hostname string
Hostname for Terraform Cloud--modules string
A directory where other Terraform modules are stored. If set, it will be scanned recursively for terraform_remote_state references.--organization string
Organization name in Terraform Cloud--tfvars-filename string
New filename for terraform.tfvars--workspace-name string
The name of the Terraform Cloud workspace (conflicts with --workspace-prefix)--workspace-prefix string
The prefix of the Terraform Cloud workspaces (conflicts with --workspace-name)--workspace-variable string
Variable that will replace terraform.workspace
```The `migrate` command performs the following file updates and runs `terraform init` to trigger Terraform to copy state to the new
* Configures a remote backend. ([?](https://www.terraform.io/docs/cloud/migrate/index.html#step-5-edit-the-backend-configuration)).
* Updates any [`terraform_remote_state`](https://www.terraform.io/docs/providers/terraform/d/remote_state.html) data sources that match the previous backend configuration.
* Replaces `terraform.workspace` with a variable of your choice, `var.environment` by default. ([?](https://www.terraform.io/docs/state/workspaces.html#current-workspace-interpolation))
* Renames `terraform.tfvars` to a name of your choice, `terraform.auto.tfvars` by default. ([?](https://www.terraform.io/docs/cloud/workspaces/variables.html#terraform-variables))#### Examples
##### Basic
```sh
terraform-cloud migrate --organization my-org --workspace-name my-ws ./path/to/module
```##### Remote State
Updates `terraform_remote_state` data sources in `~/src/tf`:
```sh
terraform-cloud migrate --modules ~/src/tf # ...
```##### Terraform Enterprise
By default, `terraform-cloud` connects to Terraform Cloud at `app.terraform.io`. Terraform Enterprise users can set a custom hostname:
```sh
terraform-cloud migrate --hostname terraform.enterprise.host # ...
```## License
MIT © [Ben Drucker](http://bendrucker.me)