Skip to main content

Terraform state viewer

Project description

Terraform lens

pre-commit unit-tests Pypi package coverage Supported versions check

Terraform lens is a CLI tool that enables developers have a summarized view of tfstate resources.

Description

It will produce a table with the resources in a given terraform tfstate with the following columns:

  • provider
  • type
  • mode
  • name
  • module

Example:

provider type mode name module
provider.aws aws_caller_identity data current_user test
provider.aws aws_dynamodb_table managed dynamodb-terraform-state-lock (None)

Features

Currently, the tool supports read the tfstate file from a local file or a remote state stored in S3.

Regarding the produced output, there are three possibilities:

  • CLI output. This will show the table directly in the terminal.
  • Markdown file. This will creates a file .tflens/terraform.tfstate.json.md in the current directory with the table.
  • HTML file. It's also possible to create an html file .tflens/terraform.tfstate.json.html in the current directory with the table.

The tool has been tested with tfstate files for the following terraform versions:

  • 0.12.0 - 0.12.29
  • 0.13.0 - 0.13.4

Install

As the content of this repo is a Pypi package, you can easily install it using pip:

pip install tflens

Usage

 tflens --help

usage: tflens [-h] [-f FILE_LOCATION] [-o OUTPUT] [-r REMOTE]

Terraform lens is a CLI tool that enables developers have a summarized view of tfstate resources.

optional arguments:
  -h, --help            show this help message and exit
  -f FILE_LOCATION, --file-location FILE_LOCATION
        Defines the location (remote or local) of the tfstate file.
        Mandatory if remote tfstate is selected.
        If empty then use the current_folder/terraform.tfstate
  -o OUTPUT, --output OUTPUT
        Defines output type (markdown|html).
        If empty outputs in terminal
  -r REMOTE, --remote REMOTE
        Defines if remote (s3) or local tfstate file.
        If empty local is used.
        When remote is defined, you also need to specify --file-location with the tfstate location
        according to the following pattern: bucket-name/tfstate-key

Examples

View table of resources for a tfstate located in the file system in the directory:

 tflens

|   provider   |        type         |   mode  |           name                | module |
|--------------|---------------------|---------|-------------------------------|--------|
| provider.aws | aws_caller_identity |   data  |        current_user           |  test  |
| provider.aws |  aws_dynamodb_table | managed | dynamodb-terraform-state-lock | (None) |

View table of resources for a tfstate located in the file system in the dev/terraform.tfstate.json path:

 tflens --file-location dev/terraform.tfstate.json

|   provider   |        type         |   mode  |           name                | module |
|--------------|---------------------|---------|-------------------------------|--------|
| provider.aws | aws_caller_identity |   data  |        current_user           |  test  |
| provider.aws |  aws_dynamodb_table | managed | dynamodb-terraform-state-lock | (None) |

Create markdown file with table of resources for a tfstate located in the file system in the directory:

 tflens --output markdown

View table of resources for a tfstate located in a S3 bucket called tflens-test-tfstate-bucket:

 tflens --file-location tflens-test-tfstate-bucket/common/terraform.tfstate --remote s3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tflens-1.0.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tflens-1.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file tflens-1.0.1.tar.gz.

File metadata

  • Download URL: tflens-1.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for tflens-1.0.1.tar.gz
Algorithm Hash digest
SHA256 010da092ea8a0770858a90fd31d1464efc5f9c58ea04c83f448121eb3679175c
MD5 52d55b9ff9a145c1f08b6eb9ad8c9d0a
BLAKE2b-256 b2352bb0e796fc2de5a24488b61210eaf41edb441cedf3dc34ea4711791a8896

See more details on using hashes here.

File details

Details for the file tflens-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tflens-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for tflens-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 167c8fa733a635e854b00410867ff076e2cda04e4b3686560295c13718ffc874
MD5 2a2a143f5cc8b2b9e952497a6028d3c7
BLAKE2b-256 2df2434c535a710463bbd3b05992ffe2415d05c1d61de749f1979460dc161f70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page