tflens
v1.5.0
Terraform Lens는 개발자가 TFSTATE 리소스에 대한 요약 된 견해를 가질 수있는 CLI 도구입니다.
주어진 Terraform tfstate의 자원이있는 테이블을 다음 열이 있습니다.
예:
| provider | type | mode | name | module |
| --------------|---------------------|---------|-------------------------------|-------- |
| provider.aws | aws_caller_identity | data | current_user | test |
| provider.aws | aws_dynamodb_table | managed | dynamodb-terraform-state-lock | - |현재이 도구는 로컬 파일 또는 S3에 저장된 원격 상태 에서 TFSTATE 파일을 읽습니다.
생산 된 출력과 관련하여 세 가지 가능성이 있습니다.
.tflens/terraform.tfstate.json.md 가 생성됩니다..tflens/terraform.tfstate.json.html 을 만들 수도 있습니다.이 도구는 다음 Terraform 버전에 대해 TFSTATE 파일로 테스트되었습니다.
이 Repo의 내용은 PYPI 패키지이므로 PIP를 사용하여 쉽게 설치할 수 있습니다.
pip install tflens➜ tflens --help
usage: tflens [-h] [-f FILE_LOCATION] [-o OUTPUT] [-r REMOTE] [-m FILTER_MODULE] [-n FILTER_NAME] [-t FILTER_TYPE] [-p FILTER_PROVIDER] [-d FILTER_MODE] [-u HTTP_USER] [-w HTTP_PASSWORD] [-v]
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 | http) 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
-s SHOW_COLUMNS, --show-columns SHOW_COLUMNS
Comma separated string list with columns to show in output. Default list is: ' provider,type,mode,name,module '
-m FILTER_MODULE, --filter-module FILTER_MODULE
Applies a regular expression to the module field in order to filter the resources list to output
-n FILTER_NAME, --filter-name FILTER_NAME
Applies a regular expression to the name field in order to filter the resources list to output
-t FILTER_TYPE, --filter-type FILTER_TYPE
Applies a regular expression to the type field in order to filter the resources list to output
-p FILTER_PROVIDER, --filter-provider FILTER_PROVIDER
Applies a regular expression to the provider field in order to filter the resources list to output
-d FILTER_MODE, --filter-mode FILTER_MODE
Applies a regular expression to the mode field in order to filter the resources list to output
-u HTTP_USER, --http-user HTTP_USER
User for http remote backend basic auth
-w HTTP_PASSWORD, --http-password HTTP_PASSWORD
Password for http remote backend basic auth
-v, --version
Show program version디렉토리의 파일 시스템에 위치한 TFSTATE의 리소스 테이블보기 :
➜ 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 | - |디렉토리의 파일 시스템에있는 TFSTATE의 리소스 테이블보기 공급자 열을 제거합니다.
➜ 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 | - |이 기능은 열 순서를 변경하는 데 사용될 수도 있습니다.
➜ tflens --show-columns " module,name,type "
| module | name | type |
| -------- | ------------------------------- | --------------------- |
| test | current_user | aws_caller_identity |
| - | dynamodb-terraform-state-lock | aws_dynamodb_table |디렉토리의 파일 시스템에 위치한 TFSTATE의 필터링 된 리소스 테이블보기 :
➜ tflens --filter-name " current "
| provider | type | mode | name | module |
| -------------- | --------------------- | --------- | ------------------------------- | -------- |
| provider.aws | aws_caller_identity | data | current_user | test |또는:
➜ tflens --filter-module " test "
| provider | type | mode | name | module |
| -------------- | --------------------- | --------- | ------------------------------- | -------- |
| provider.aws | aws_caller_identity | data | current_user | test |또는:
➜ tflens --filter-name " current " --filter-module " test "
| provider | type | mode | name | module |
| -------------- | --------------------- | --------- | ------------------------------- | -------- |
| provider.aws | aws_caller_identity | data | current_user | test | dev/terraform.tfstate.json Path의 파일 시스템에 위치한 TFSTATE의 리소스 테이블보기 :
➜ 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 | - |디렉토리의 파일 시스템에 위치한 TFSTATE에 대한 리소스 테이블로 Markdown 파일을 만듭니다.
➜ tflens --output markdown tflens-test-tfstate-bucket 이라는 S3 버킷에 위치한 tfstate에 대한 자원 테이블보기 :
➜ tflens --file-location tflens-test-tfstate-bucket/common/terraform.tfstate --remote s3