Package: tflens
Terraform lensTerraform lens is a CLI tool that enables developers have a summarized view of tfstate resources.DescriptionIt will produce a table with the resources in a given terraform tfstate with the following columns:providertypemodenamemoduleExample:|   provider   |        type         |   mode  |           name                | module |
|--------------|---------------------|---------|-------------------------------|--------|
| provider.aws | aws_caller_identity |   data  |        current_user           |  test  |
| provider.aws |  aws_dynamodb_table | managed | dynamodb-terraform-state-lock |   -    |FeaturesCurrently, the tool supports read the tfstate file from alocal fileor aremote state stored in S3.Regarding the produced output, there are three possibilities:CLI output. This will show the table directly in the terminal.Markdownfile. This will creates a file.tflens/terraform.tfstate.json.mdin the current directory with the table.HTMLfile. It's also possible to create an html file.tflens/terraform.tfstate.json.htmlin the current directory with the table.The tool has been tested with tfstate files for the following terraform versions:0.12.0 - 0.12.290.13.0 - 0.13.70.14.0 - 0.14.110.15.0 - 0.14.51.0.0InstallAs the content of this repo is a Pypi package, you can easily install it using pip:pipinstalltflensUsage➜tflens--help

usage:tflens[-h][-fFILE_LOCATION][-oOUTPUT][-rREMOTE][-mFILTER_MODULE][-nFILTER_NAME][-tFILTER_TYPE][-pFILTER_PROVIDER][-dFILTER_MODE][-uHTTP_USER][-wHTTP_PASSWORD][-v]TerraformlensisaCLItoolthatenablesdevelopershaveasummarizedviewoftfstateresources.

optionalarguments:-h,--helpshowthishelpmessageandexit-fFILE_LOCATION,--file-locationFILE_LOCATIONDefinesthelocation(remoteorlocal)ofthetfstatefile.Mandatoryifremotetfstateisselected.Ifemptythenusethecurrent_folder/terraform.tfstate-oOUTPUT,--outputOUTPUTDefinesoutputtype(markdown|html).Ifemptyoutputsinterminal-rREMOTE,--remoteREMOTEDefinesifremote(s3|http)orlocaltfstatefile.Ifemptylocalisused.Whenremoteisdefined,youalsoneedtospecify--file-locationwiththetfstatelocationaccordingtothefollowingpattern:bucket-name/tfstate-key-sSHOW_COLUMNS,--show-columnsSHOW_COLUMNSCommaseparatedstringlistwithcolumnstoshowinoutput.Defaultlistis:'provider,type,mode,name,module'-mFILTER_MODULE,--filter-moduleFILTER_MODULEAppliesaregularexpressiontothemodulefieldinordertofiltertheresourceslisttooutput-nFILTER_NAME,--filter-nameFILTER_NAMEAppliesaregularexpressiontothenamefieldinordertofiltertheresourceslisttooutput-tFILTER_TYPE,--filter-typeFILTER_TYPEAppliesaregularexpressiontothetypefieldinordertofiltertheresourceslisttooutput-pFILTER_PROVIDER,--filter-providerFILTER_PROVIDERAppliesaregularexpressiontotheproviderfieldinordertofiltertheresourceslisttooutput-dFILTER_MODE,--filter-modeFILTER_MODEAppliesaregularexpressiontothemodefieldinordertofiltertheresourceslisttooutput-uHTTP_USER,--http-userHTTP_USERUserforhttpremotebackendbasicauth-wHTTP_PASSWORD,--http-passwordHTTP_PASSWORDPasswordforhttpremotebackendbasicauth-v,--versionShowprogramversionExamplesView 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|-|View table of resources for a tfstate located in the file system in the directory removing provider column:➜tflens--show-columns"type,mode,name,module"|type|mode|name|module||---------------------|---------|-------------------------------|--------||aws_caller_identity|data|current_user|test||aws_dynamodb_table|managed|dynamodb-terraform-state-lock|-|This feature can be also used to change columns order:➜tflens--show-columns"module,name,type"|module|name|type||--------|-------------------------------|---------------------||test|current_user|aws_caller_identity||-|dynamodb-terraform-state-lock|aws_dynamodb_table|View filtered table of resources for a tfstate located in the file system in the directory:➜tflens--filter-name"current"|provider|type|mode|name|module||--------------|---------------------|---------|-------------------------------|--------||provider.aws|aws_caller_identity|data|current_user|test|Or:➜tflens--filter-module"test"|provider|type|mode|name|module||--------------|---------------------|---------|-------------------------------|--------||provider.aws|aws_caller_identity|data|current_user|test|Or:➜tflens--filter-name"current"--filter-module"test"|provider|type|mode|name|module||--------------|---------------------|---------|-------------------------------|--------||provider.aws|aws_caller_identity|data|current_user|test|View table of resources for a tfstate located in the file system in thedev/terraform.tfstate.jsonpath:➜tflens--file-locationdev/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|-|Create markdown file with table of resources for a tfstate located in the file system in the directory:➜tflens--outputmarkdownView table of resources for a tfstate located in a S3 bucket calledtflens-test-tfstate-bucket:➜tflens--file-locationtflens-test-tfstate-bucket/common/terraform.tfstate--remotes3