{"id":26575597,"url":"https://github.com/tomarv2/tfremote","last_synced_at":"2025-03-23T02:19:36.947Z","repository":{"id":45560011,"uuid":"260555816","full_name":"tomarv2/tfremote","owner":"tomarv2","description":"Terraform wrapper to manage state across multiple cloud providers(AWS, GCP, and Azure)","archived":false,"fork":false,"pushed_at":"2024-08-01T21:32:30.000Z","size":2067,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-03T22:09:39.444Z","etag":null,"topics":["aws","azure","gcloud","python","python3","terraform","terraform-scripts"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomarv2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-05-01T20:49:55.000Z","updated_at":"2024-12-18T07:41:39.000Z","dependencies_parsed_at":"2022-09-10T02:23:22.152Z","dependency_job_id":"c0a5ef20-298e-4aa0-8a4a-6fe85e20ccfe","html_url":"https://github.com/tomarv2/tfremote","commit_stats":{"total_commits":68,"total_committers":3,"mean_commits":"22.666666666666668","dds":0.3529411764705882,"last_synced_commit":"59b01d18c8574b8b3d3c8f3239f3fd9940484299"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomarv2%2Ftfremote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomarv2%2Ftfremote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomarv2%2Ftfremote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomarv2%2Ftfremote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomarv2","download_url":"https://codeload.github.com/tomarv2/tfremote/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978366,"owners_count":20541840,"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":["aws","azure","gcloud","python","python3","terraform","terraform-scripts"],"created_at":"2025-03-23T02:19:36.352Z","updated_at":"2025-03-23T02:19:36.945Z","avatar_url":"https://github.com/tomarv2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/tomarv2/tfremote/actions/workflows/checks.yml\" alt=\"Check\"\u003e\n        \u003cimg src=\"https://github.com/tomarv2/tfremote/actions/workflows/checks.yml/badge.svg?branch=main\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.apache.org/licenses/LICENSE-2.0\" alt=\"GitHub tag\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/tomarv2/tfremote\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/tomarv2/tfremote/tags\" alt=\"GitHub tag\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/v/tag/tomarv2/tfremote\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/tomarv2/tfremote/pulse\" alt=\"Activity\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/commit-activity/m/tomarv2/tfremote\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://stackoverflow.com/users/6679867/tomarv2\" alt=\"Stack Exchange reputation\"\u003e\n        \u003cimg src=\"https://img.shields.io/stackexchange/stackoverflow/r/6679867\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://discord.gg/XH975bzN\" alt=\"chat on Discord\"\u003e\n        \u003cimg src=\"https://img.shields.io/discord/813961944443912223?logo=discord\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://twitter.com/intent/follow?screen_name=varuntomar2019\" alt=\"follow on Twitter\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/follow/varuntomar2019?style=social\u0026logo=twitter\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Terraform Remote State Manager([tfremote](https://pypi.org/project/tfremote/))\n\n**tf** is a python package for managing terraform remote state for: Google(Gcloud), AWS, and Azure.\nIt sets a defined structure for all cloud providers by removing the overheard of configuring and managing the path in storage buckets.\n\nIt works with:\n\n:point_right: Google Storage Bucket\n\n:point_right: AWS S3\n\n:point_right: Azure Storage\n\n\u003e ❗️ **Note** Best practice is to make sure buckets are versioned.\n\n## Install package\n\n```\npip install tfremote --upgrade\n```\n\n## Environment setup\n\n- Install Python 3.6+\n\n- Using virtualenv is strongly recommended:\n\n```\npython3 -m venv \u003cvenv name\u003e\n```\n\n- Terraform 0.14.0 and above (download: https://www.terraform.io/downloads.html)\n\nDefault log level is `WARNING`, to change:\n\n`export TF_LOG_LEVEL` to any of these: `'CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'`\n\n\u003e ❗️ **Important** - Two variables are required for using `tf` package (used set creat path in remote storage):\n\u003e\n\u003e - teamid\n\u003e - prjid\n\u003e\n\u003e Required variables can be defined using:\n\u003e\n\u003e - As `inline variables` e.g.: `-var='teamid=demo-team' -var='prjid=demo-project'`\n\u003e - Inside `.tfvars` file e.g.: `-var-file=\u003ctfvars file location\u003e `\n\u003e\n\u003e Two optional variables:\n\u003e\n\u003e `workspace` and `state_key` can be defined using:\n\u003e\n\u003e - `-w=\u003cworkspace_name\u003e`. If no workspace is provided `default` workspace is used.\n\u003e\n\u003e - `s=\u003cstate_key name\u003e`. If no key is provided `terraform` is used.\n\u003e\n\u003e Path created in S3 backend: `/\u003cteamid\u003e/\u003cprjid\u003e/\u003cworkspace\u003e/\u003cstate-key\u003e.tfstate`\n\u003e\n\u003e For more information refer to [Terraform documentation](https://www.terraform.io/docs/language/values/variables.html)\n\n## Setup environment variables\n\n### Workspace list file location `TF_WORKSPACE_FILE_LOCATION`\n\n```\nexport TF_WORKSPACE_FILE_LOCATION=\u003cworkspace yml file location\u003e\n```\n\nReference file: [link](scripts/workspaces.yml)\n\n### AWS\n\n\u003e ❗️ **Important** - s3 bucket for remote state should reside in `us-west-2`\n\nSet these env variables:\n\n```\nexport TF_AWS_BUCKET=\u003cyour_remote_state_bucket_name\u003e\nexport TF_AWS_BUCKET_REGION=us-west-2\n```\n\nOne of below environment variable is required:\n\n```\nexport TF_AWS_PROFILE=\u003caws profile to use\u003e\n```\n\nor\n\n```\nexport AWS_ACCESS_KEY_ID=\u003caws access key\u003e\nexport AWS_SECRET_ACCESS_KEY=\u003caws secret access key\u003e\n```\n\n### Azure\n\nTo create storage for remote state there is handy script.\n\nRun `scripts/remote_state.sh` (fill in the required information)\n\nSet below env variables:\n\n```\nexport TF_AZURE_STORAGE_ACCOUNT=\u003cremote state storage account name\u003e\nexport TF_AZURE_CONTAINER=\u003cremote state container\u003e\nexport ARM_ACCESS_KEY=\u003cstorage account access key\u003e\n```\n\n### GCP(gcloud)\n\nhttps://cloud.google.com/community/tutorials/managing-gcp-projects-with-terraform\n\nSet below env variables:\n\n```\nexport TF_GCLOUD_BUCKET=\u003cremote state storage bucket name\u003e\nexport TF_GCLOUD_CREDENTIALS=json credentials file path\u003e\n```\n\n## Usage\n\n### For GCP(gcloud):\n\n```\ntf plan -c=gcloud -var=teamid=demo-team -var=prjid=demo-app -w=demo-workspace\n```\n\nThe structure in Google Storage Bucket:\n\n![alt text](docs/images/google_tf.png)\n\n### For AWS:\n\n```\ntf plan -c=aws -var=teamid=demo-team -var=prjid=demo-app -w=demo-workspace\n```\n\nThe structure in AWS S3:\n\n![alt text](docs/images/aws_tf.png)\n\nIf you need to specify `state_key` in S3, specify `-s=tryme-key`\n\n### For Azure:\n\n```\ntf plan -c=azure -var=teamid=demo-team -var=prjid=demo-app -w=demo-workspace\n```\n\nThe structure in Azure Storage:\n\n![alt text](docs/images/azure_tf.png)\n\n### For more available options:\n\n```\ntf --help\nusage: tf [-h] [-var] [-var-file] [-c] [-w] [-wp] [-s] [-no-color] [-json] [-out] [-f] [-nf] [-v]\n\nTerraform remote state wrapper package\n--------------------------------------\nUsage: Set below env variables to begin (more information: https://github.com/tomarv2/tfremote):\nTF_WORKSPACE_FILE_LOCATION\naws: TF_AWS_BUCKET, TF_AWS_BUCKET_REGION=us-west-2, TF_AWS_PROFILE or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY\nazure: TF_AZURE_STORAGE_ACCOUNT, TF_AZURE_CONTAINER, ARM_ACCESS_KEY\ngcloud: TF_GCLOUD_BUCKET, TF_GCLOUD_CREDENTIALS\n\noptional arguments:\n  -h, --help  show this help message and exit\n  -var        Set Terraform configuration variable. This flag can be set multiple times\n  -var-file   Set Terraform configuration variables from a file. This flag can be set multiple times\n  -c          Specify cloud provider (default: 'aws'). Supported values: gcloud, aws, or azure\n  -w          Specify existing workspace name(default: 'default')\n  -wp         Overwrite workspace directory path structure\n  -s          File name in remote state (default: 'terraform.tfstate')\n  -no-color   Disables terminal formatting sequences in the output\n  -json       Enables the machine readable JSON UI output\n  -out        Writes the generated plan to the given filename in an opaque file format\n  -f          Enable FIPS endpoints (default: True)\n  -nf         Disable FIPS endpoints\n  -v          show program's version number and exit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomarv2%2Ftfremote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomarv2%2Ftfremote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomarv2%2Ftfremote/lists"}