{"id":15292483,"url":"https://github.com/fujiwara/tfstate-lookup","last_synced_at":"2025-05-15T08:08:42.816Z","repository":{"id":38080621,"uuid":"249898286","full_name":"fujiwara/tfstate-lookup","owner":"fujiwara","description":"Lookup resource attributes in tfstate.","archived":false,"fork":false,"pushed_at":"2025-03-31T22:13:12.000Z","size":16633,"stargazers_count":113,"open_issues_count":14,"forks_count":21,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T12:18:22.607Z","etag":null,"topics":["go","terraform","tfstate"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fujiwara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fujiwara"]}},"created_at":"2020-03-25T05:53:48.000Z","updated_at":"2025-04-10T09:40:17.000Z","dependencies_parsed_at":"2024-09-17T08:06:46.819Z","dependency_job_id":"07e241c0-4c6a-413a-862f-78aff0601015","html_url":"https://github.com/fujiwara/tfstate-lookup","commit_stats":{"total_commits":166,"total_committers":16,"mean_commits":10.375,"dds":0.3313253012048193,"last_synced_commit":"4b5e629622b8d90c186659c272084c585753ed24"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Ftfstate-lookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Ftfstate-lookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Ftfstate-lookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Ftfstate-lookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fujiwara","download_url":"https://codeload.github.com/fujiwara/tfstate-lookup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248877968,"owners_count":21176244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","terraform","tfstate"],"created_at":"2024-09-30T16:18:09.940Z","updated_at":"2025-04-14T12:18:30.498Z","avatar_url":"https://github.com/fujiwara.png","language":"Go","funding_links":["https://github.com/sponsors/fujiwara"],"categories":[],"sub_categories":[],"readme":"# tfstate-lookup\n\nLookup resource attributes in tfstate.\n\n## Install\n\n### homebrew\n\n```\n$ brew install fujiwara/tap/tfstate-lookup\n```\n\n### [Binary releases](https://github.com/fujiwara/tfstate-lookup/releases)\n\n## Usage (command)\n\n```\nUsage of tfstate-lookup:\n  -dump\n        dump all resources\n  -i    interactive mode\n  -j    run jid after selecting an item\n  -s string\n        tfstate file path or URL (default \"terraform.tfstate\")\n  -s3-endpoint-url string\n        S3 endpoint URL\n  -state string\n        tfstate file path or URL (default \"terraform.tfstate\")\n  -timeout duration\n        timeout for reading tfstate\n```\n\nSupported URL schemes are http(s), s3, gs, azurerm, file or remote (for Terraform Cloud and Terraform Enterprise).\n\n```console\n$ tfstate-lookup -s .terraform/terraform.tfstate aws_vpc.main.id\nvpc-1a2b3c4d\n\n$ tfstate-lookup aws_vpc.main\n{\n  \"arn\": \"arn:aws:ec2:ap-northeast-1:123456789012:vpc/vpc-1a2b3c4d\",\n  \"assign_generated_ipv6_cidr_block\": false,\n  \"cidr_block\": \"10.0.0.0/16\",\n  \"default_network_acl_id\": \"acl-001234567890abcde\",\n  \"default_route_table_id\": \"rtb-001234567890abcde\",\n  \"default_security_group_id\": \"sg-01234567890abcdef\",\n  \"dhcp_options_id\": \"dopt-64569903\",\n  \"enable_classiclink\": false,\n  \"enable_classiclink_dns_support\": false,\n  \"enable_dns_hostnames\": true,\n  \"enable_dns_support\": true,\n  \"id\": \"vpc-1a2b3c4d\",\n  \"instance_tenancy\": \"default\",\n  \"ipv6_association_id\": \"\",\n  \"ipv6_cidr_block\": \"\",\n  \"main_route_table_id\": \"rtb-001234567890abcde\",\n  \"owner_id\": \"123456789012\",\n  \"tags\": {\n    \"Name\": \"main\"\n  }\n}\n```\n\nA remote state is supported only S3, GCS, AzureRM and Terraform Cloud / Terraform Enterprise backend currently.\n\n### Interactive mode\n\nYou can use interactive mode with `-i` option.\n\n```console\n$ tfstate-lookup -i\nSearch: █\n? Select an item: \n  ▸ aws_acm_certificate.foo\n    aws_acm_certificate_validation.foo\n    aws_cloudwatch_log_group.foo\n    aws_ecs_cluster.foo\n...\n```\n\nWhen you select an item, it shows the attributes of the resource.\n\n### Run jid after selecting an item\n\nYou can run [jid](https://github.com/simeji/jid) after selecting an item with `-j` option.\n\njid is a JSON incremental digger.\n\n`tfstate-lookup -i -j` runs jid after selecting an item.\n\n`tfstate-lookup -j some.resource` runs jid for the attributes of the resource.\n\ntfstate-lookup integrates jid as a library, so you don't need to install jid command.\n\nSee also [simiji/jid](https://github.com/simeji/jid).\n\n### Dump all resources, outputs, and data sources in tfstate\n\nYou can dump all resources, outputs, and data sources in tfstate with `-dump` option.\n\n```console\n$ tfstate-lookup -dump\n```\n\nThe output is a JSON object. The keys are the address of the resource, output, or data source. The values are the same as the lookup result.\n\n```jsonnet\n{\n  \"aws_vpc.main\": {\n    \"arn\": \"arn:aws:ec2:ap-northeast-1:123456789012:vpc/vpc-1a2b3c4d\",\n    \"assign_generated_ipv6_cidr_block\": false,\n    // ...\n  },\n  \"data.aws_ami.foo\": {\n    \"arn\": \"arn:aws:ec2:ap-northeast-1:123456789012:ami/ami-1a2b3c4d\",\n    // ...\n  },\n  \"output.foo\": \"bar\",\n  // ...\n}\n```\n\n## Usage (Go package)\n\nSee details in [godoc](https://pkg.go.dev/github.com/fujiwara/tfstate-lookup/tfstate).\n\n```go\npackage main\n\nimport(\n    \"fmt\"\n    \"os\"\n\n    \"github.com/fujiwara/tfstate-lookup/tfstate\"\n)\n\nfunc main() {\n    state, _ := tfstate.ReadURL(ctx, \"s3://mybucket/terraform.tfstate\")\n    attrs, _ := state.Lookup(\"aws_vpc.main.id\")\n    fmt.Println(attrs.String())\n}\n```\n\n\n## Supported tfstate URL format\n\n- Local file `file://path/to/terraform.tfstate`\n- HTTP/HTTPS `https://example.com/terraform.tfstate`\n- Amazon S3 `s3://{bucket}/{key}`\n- Terraform Cloud `remote://app.terraform.io/{organization}/{workspaces}`\n  - `TFE_TOKEN` environment variable is required.\n- Google Cloud Storage `gs://{bucket}/{key}`\n- Azure Blog Storage\n  - `azurerm://{resource_group_name}/{storage_account_name}/{container_name}/{blob_name}`\n  - `azurerm://{subscription_id}@{resource_group_name}/{storage_account_name}/{container_name}/{blob_name}`\n\n### S3 endpoint URL support\n\nYou can specify the S3 endpoint URL with `-s3-endpoint-url` option. `AWS_ENDPOINT_URL_S3` environment variable is also supported.\n\n```console\n$ tfstate-lookup -s3-endpoint-url http://localhost:9000 s3://mybucket/terraform.tfstate\n\n$ AWS_ENDPOINT_URL_S3=http://localhost:9000 tfstate-lookup s3://mybucket/terraform.tfstate\n```\n\nThis option is useful for S3 compatible storage services.\n\n### Terraform Workspace support\n\nYou can specify the Terraform workspace with `TF_WORKSPACE` environment variable.\n\n## LICENSE\n\n[Mozilla Public License Version 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Ftfstate-lookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffujiwara%2Ftfstate-lookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Ftfstate-lookup/lists"}