Command Line Interface for Terraform Enterprise/Cloud ( tecli )

Overview

Photo by Gabriel Menchaca on Unsplash

Photo by Gabriel Menchaca on Unsplash

GitHub issuesGitHub forksGitHub starsGitHub licenseTwitter

Command Line Interface for Terraform Enterprise/Cloud ( tecli )

In a world where everything is Terraform, teams use Terraform Cloud API to manage their workloads. TECLI increases teams productivity by facilitating such interaction and by providing easy commands that can be executed on a terminal or on CI/CD systems.

Table of Contents


Screenshots


Expand
how-to-configure
How to configure
how-to-create-a-workspace
How to create a workspace
how-to-create-a-workspace-linked-to-a-repository
How to create a workspace linked to a repository
how-to-create-a-run
How to create a run
how-to-read-plan-logs
How to read plan logs
how-to-read-apply-logs
How to read apply logs
how-to-delete-a-workspace
How to delete a workspace

Usage


Expand

tecli --help

Prerequisites


Expand

Installing


Expand

Look for the latest release published and download the binary according to your OS and platform. For more information, check the Installation Wiki page.

Commands

Command Line Interface for Terraform Enterprise/Cloud

Usage:
   [command]

Available Commands:
  apply                 An apply represents the results of applying a Terraform Run's execution plan.
  configuration-version A configuration version is a resource used to reference the uploaded configuration files.
  configure             Configures tecli settings
  help                  Help about any command
  o-auth-client         An OAuth Client represents the connection between an organization and a VCS provider.
  o-auth-token          The oauth-token object represents a VCS configuration which includes the OAuth connection and the associated OAuth token. This object is used when creating a workspace to identify which VCS connection to use.
  plan                  A plan represents the execution plan of a Run in a Terraform workspace.
  run                   A run performs a plan and apply, using a configuration version and the workspace’s current variables.
  ssh-key               The ssh-key object represents an SSH key which includes a name and the SSH private key. An organization can have multiple SSH keys available.
  variable              Operations on variables.
  version               Displays the version of tecli and all installed plugins
  workspace             Workspaces represent running infrastructure managed by Terraform.

Flags:
  -c, --config string          Override the default directory location of the application. Example --config=tecli to locate under the current working directory.
  -h, --help                   help for this command
  -l, --log string             Enable or disable logs (found at $HOME/.tecli/logs.json). Log outputs will be shown on default output. (default "disable")
      --log-file-path string   Log file path. (default "/Users/valterh/.tecli/logs.json")
  -o, --organization string    Terraform Cloud Organization name
  -p, --profile string         Use a specific profile from your credentials and configurations file. (default "default")
  -v, --verbosity string       Valid log level:panic,fatal,error,warn,info,debug,trace). (default "error")

Use " [command] --help" for more information about a command.

Top Commands

All the following commands require TEAM API TOKEN. You can run tecli configure create to configure TECLI options. Alternatively, you can export environment varibles.

To export environment variables:

# on Linux:
export TFC_TEAM_TOKEN=XXX

# on Windows (powershell):
$Env:TFC_TEAM_TOKEN="XXX"

To list all workspaces part of an organization:

tecli workspace list -o=${TFC_ORGANIZATION} -p=${PROFILE}

To find a workspace by name (instead of listing all workspaces and look for its ID):

tecli workspace find-by-name --organization=${TFC_ORGANIZATION} --name=${TFC_WORKSPACE_NAME}

To create a workspace and allow destroy plans:

tecli workspace create --organization=${TFC_ORGANIZATION} --name=${TFC_WORKSPACE_NAME} --allow-destroy-plan=true

To create a plan (if you want to upload your code to Terraform Cloud):

tecli configuration-version create --workspace-id=${WORKSPACE_ID}
tecli configuration-version upload --url=${CV_UPLOAD_URL} --path=./
tecli run create --workspace-id=${WORKSPACE_ID} --comment="${COMMENT}" 

To check the staus of a run:

tecli run read --id=${RUN_ID}

You combine some BASH scripting and check if your plan has finished:

while true; do STATUS=$(tecli run read --id=${RUN_ID} | jq -r ".Status"); if [ "${STATUS}" != "pending" ]; then break; else echo "RUN STATUS:${STATUS}, IF 'pending' TRY DISCARD PREVIOUS PLANS. SLEEP 5 seconds" && sleep 5; fi; done

To display the logs of a plan:

tecli plan logs --id=${PLAN_ID}

To leave a comment on a plan:

tecli run create --workspace-id=${WORKSPACE_ID} --comment="${COMMENT}" --is-destroy=true

To discard a run:

tecli run discard --id=${RUN_ID}

To discard all runs:

tecli run discard-all --workspace-id=${WORKSPACE_ID}

To apply a plan:

tecli run apply --id=${RUN_ID} --comment="${COMMENT}"

To display the apply logs:

tecli apply logs --id=${APPLY_ID}

To create a sensitive terraform variable:

tecli variable update --key=${VARIABLE_KEY} --value=${VARIABLE_VALUE} --workspace-id=${WORKSPACE_ID} --category=terraform --sensitive=true

To create a sensitive environment variable:

tecli variable create --key=${VARIABLE_KEY} --value=${VARIABLE_VALUE} --workspace-id=${WORKSPACE_ID} --category=env --sensitive=true

# AWS CLI ENVIRONMENT VARIABLES
tecli variable create --key=AWS_ACCESS_KEY_ID --value=${AWS_ACCESS_KEY_ID} --workspace-id=${WORKSPACE_ID} --category=env --sensitive=true
tecli variable create --key=AWS_SECRET_ACCESS_KEY --value=${AWS_SECRET_ACCESS_KEY} --workspace-id=${WORKSPACE_ID} --category=env --sensitive=true
tecli variable create --key=AWS_DEFAULT_REGION --value=${AWS_DEFAULT_REGION} --workspace-id=${WORKSPACE_ID} --category=env --sensitive=true

## IF YOU ALSO NEED TO EXPORT AWS_SESSION_TOKEN:
tecli variable create --key=AWS_SESSION_TOKEN --value=${AWS_SESSION_TOKEN} --workspace-id=${WORKSPACE_ID} --category=env --sensitive=true

To delete all variables (be careful):

tecli variable delete-all --workspace-id=${WORKSPACE_ID}

Contributors


Expand
Name Email Role
Silva, Valter [email protected] AWS Professional Services - Cloud Architect
Dhingra, Prashit AWS Professional Services - Cloud Architect

References


Expand

License


This project is licensed under the Apache License 2.0.

For more information please read LICENSE.

Copyright


Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Comments
  • Go-TFE 1.0

    Go-TFE 1.0

    Hi!

    In a few days, HashiCorp will be releasing a major version for the Go API client for Terraform Cloud.

    I am reaching out for mainly two reasons.

    First to give your team heads up that this release will contain breaking changes. We are aware that your project relies on our client and we will not want you to be caught by surprise if you decide to upgrade :)

    But I also wanted to check if you'd be interested in trying out our beta version prior to the official release of 1.0. We'd love to have your feedback to find out if you were able to use this version smoothly. This pre-release version will be available very soon. Would you be able to try it out next week?

    Best, Luces

    opened by uturunku1 2
  • Command line argument differs from usage

    Command line argument differs from usage

    The tecli workspace --help shows docs that would indicate parameters like --workspace-name and --organization-name are actually --name and --organization respectively.

    opened by darkn3rd 1
  • bug: make tecli/test fails

    bug: make tecli/test fails

    Hi, great tool :) I skimmed through the contribution guideline and could not find any steps to build/test. So I dug through the Makefile and found the tecli/test is twice. I removed one and got the error:

    make tecli/test
    === RUN   TestConfigureCmdFlags
    === RUN   TestConfigureCmdFlags/empty
    FATA[0000] unable to read manual from box
    exit status 1
    FAIL	gitlab.aws.dev/devops-aws/tecli/tests	0.205s
    make: *** [tecli/test] Error 1
    

    It would be lovely to have a local working test setup if possible :)

    opened by mavogel 1
  • Make standard output the default output

    Make standard output the default output

    Description of changes: Currently I'm not able to output some of the commands outputs into an external file. The reason is because at the code we are using the command output rather than the terminal output.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by valter-silva-au 0
  • Bugfix: local tests

    Bugfix: local tests

    Issue #4

    Description of changes: Allow tests to be executed locally.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by valter-silva-au 0
  • Bugfix: command line argument differs from usage

    Bugfix: command line argument differs from usage

    *Issue: 8

    Description of changes: Update documentation to accurately reflect the expected flag name.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by valter-silva-au 0
  • Develop

    Develop

    Description of changes:

    • Create command that allows operations on variables.
    • Add documentation about variable command

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    enhancement 
    opened by valter-silva-au 0
  • Feature/variables

    Feature/variables

    Description of changes:

    Allow the user to manage variables on a workspace.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    enhancement 
    opened by valter-silva-au 0
  • Feature/docker image

    Feature/docker image

    Description of changes:

    Build CLI on Docker Golang Alpine image. Build CLI on Docker Ubuntu 20.04 iamge.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by valter-silva-au 0
  • Discard all runs

    Discard all runs

    Description of changes:

    Allow users to discard all runs for a particular workspace.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by valter-silva-au 0
  • Switch to standalone cobra-cli dependency

    Switch to standalone cobra-cli dependency

    Switches to use the extracted cobra-cli command since it is being removed from the github.com/spf13/cobra module (xref https://github.com/spf13/cobra/issues/1597)

    opened by liggitt 0
  • Can't find workspace that does exist

    Can't find workspace that does exist

    When running:

     tecli workspace find-by-name --name=${TFC_WORKSPACE_NAME} > workspace.json 2>error.txt || true
    

    We sometimes encounter 'not found|no workspace was found' when the workspace does exist.

    We think this happens because we have over 40 workspaces and when you run the terraform.io api call it paginates the results with 20 workspaces per list. This means that if you haven't deployed to the workspace for a while it will move down the list and not be found. We workaround this by changing the terraform version in the UI then change it back to the original version so that its at the top of the recently updated terraform list.

    It would be good if the find-by-name returns all the results instead of just the first 20 paginated results.

    opened by Rosalind-Fletcher 0
Releases(0.4.0-alpha)
Owner
Amazon Web Services - Labs
AWS Labs
Amazon Web Services - Labs
Go-wechat-robot-sender - Using command line to send msg to Wechat enterprise by Go

Go-wechat-robot-sender - Using command line to send msg to Wechat enterprise by Go

Jinxin 1 Jan 28, 2022
Reads from existing Cloud Providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration

TerraCognita Imports your current Cloud infrastructure to an Infrastructure As Code Terraform configuration (HCL) or/and to a Terraform State. At Cycl

Cycloid 1.3k Oct 3, 2022
Rclone ("rsync for cloud storage") is a command line program to sync files and directories to and from different cloud storage providers.

Rclone ("rsync for cloud storage") is a command line program to sync files and directories to and from different cloud storage providers.

rclone 34.7k Sep 27, 2022
Rclone ("rsync for cloud storage") is a command-line program to sync files and directories to and from different cloud storage providers.

Website | Documentation | Download | Contributing | Changelog | Installation | Forum Rclone Rclone ("rsync for cloud storage") is a command-line progr

null 0 Nov 5, 2021
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

chenen 0 Jan 16, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 2.1k Oct 2, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

null 0 Nov 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Venky 0 Dec 22, 2021
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

Kaleido 1 Mar 1, 2022
a command line interface to orbit.love

orbit-cli NAME: orbit-cli - a command line interface to orbit.love USAGE: orbit-cli [global options] command [command options] [arguments...]

Geoffrey Huntley 4 May 18, 2021
Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go.

What is Lux? Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go. Lux provides it's users with the abilit

BanDev 44 Sep 24, 2022
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

null 38 Sep 16, 2022
Command line interface for flomo.

flomo-cli A Golang based command line interface of flomo. 中文说明 Features Type and save to flomo using command line. Editor mode supports, able to use v

Eason Yang 15 Sep 19, 2022
Gofire 🔥 Command Line Interface Generator tool for Go

Gofire ?? : Command Line Interface Generator tool for Go Introduction Gofire is the tool for Go that automatically generates a command line interface

Kostiantyn Masliuk 107 Aug 18, 2022
Command line interface for control iTunes

iTunes CLI Command line interface for control iTunes Description You can control iTunes operations from command line. Equipments macOS Sierra or later

ktr 16 May 16, 2022
A command line interface for trying out Repustate's multilingual semantic search

rcli A command line interface for trying out Repustate's multilingual semantic search. Install & Usage Download the binary for your OS. Make sure it's

Repustate 5 Nov 26, 2020
Inotify-tools is a C library and a set of command-line programs providing a simple interface to inotify.

inotify-tools This is a package of some commandline utilities relating to inotify. The general purpose of this package is to allow inotify's features

null 2.6k Sep 26, 2022
An unofficial command line interface (CLI) for ASPEN's Oneliner application

Overview OlxCLI is an unofficial command line interface (CLI) for ASPEN's Oneliner application. The CLI provides commands for running common fault sim

Isaac 0 Jan 3, 2022
kcli: command line interface tool to interact with K8trics API server as well as manage its lifecycle

K8trics CLI (kcli) kcli is command line interface tool to interact with K8trics API server as well as manage its lifecycle. kcli can provision and dep

null 3 Dec 15, 2021