{"id":26244560,"url":"https://github.com/wobondar/tfconfig","last_synced_at":"2025-04-23T16:20:55.489Z","repository":{"id":52997170,"uuid":"130904200","full_name":"wobondar/tfconfig","owner":"wobondar","description":"Terraform configuration manager","archived":false,"fork":false,"pushed_at":"2022-11-30T15:30:17.000Z","size":43,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T06:14:39.176Z","etag":null,"topics":["aws-sdk-go","aws-ssm","dotenv","terraform","terraform-aws","terraform-configuration","terraform-dotenv","terraform-scripts","terraform-ssm"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wobondar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-24T19:30:53.000Z","updated_at":"2022-08-04T08:47:40.000Z","dependencies_parsed_at":"2022-08-23T23:10:56.845Z","dependency_job_id":null,"html_url":"https://github.com/wobondar/tfconfig","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobondar%2Ftfconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobondar%2Ftfconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobondar%2Ftfconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobondar%2Ftfconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wobondar","download_url":"https://codeload.github.com/wobondar/tfconfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250468278,"owners_count":21435454,"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-sdk-go","aws-ssm","dotenv","terraform","terraform-aws","terraform-configuration","terraform-dotenv","terraform-scripts","terraform-ssm"],"created_at":"2025-03-13T11:28:12.958Z","updated_at":"2025-04-23T16:20:55.435Z","avatar_url":"https://github.com/wobondar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tfconfig\n\n## Terraform configuration manager\n\nEnvironment variables:\n\n`CI` - if true or 1, confirmation before any changes will be skipped\n\n```\nusage: tfconfig [\u003cflags\u003e] \u003ccommand\u003e [\u003cargs\u003e ...]\n\nTerraform configuration manager\n\nFlags:\n  -h, --help       Show context-sensitive help (also try --help-long and --help-man).\n  -v, --version    Show application version.\n  -c, --ci         CI flag, default 'false', if 'true' that you will not be asked before changes\n  -p, --path=PATH  Terraform project path\n  -V, --verbose    Verbose mode, default 'false'\n\nCommands:\n  help [\u003ccommand\u003e...]\n    Show help.\n\n\n  env \u003cenvironment\u003e\n    Switch Terraform project environment\n\n\n  dotenv [\u003cflags\u003e] \u003cenvironment\u003e [\u003cdotEnvFile\u003e]\n    Generate .env file or expose configuration into env vars from Parameter Store\n\n    -d, --decrypt  Will attempt to decrypt the parameter, default: true. use --no-decrypt to disable it\n    -e, --export   Prints vars prepared for export to env via eval like 'export VAR_NAME=var_value\\n'\n```\n\n\n## Commands\n\n### env\n\nSwitches Terraform environment for you project by generating `environment.tf`\n\n`config.tf` must be exists inside your project folder\n\n`aws-terraform-modules` the folder should be somewhere near the project and have the structure, see example above\n\n\n#### env example\n\n```\n$ tfconfig env dev\n[INFO]  Path:   /Volumes/Secured/user/git/your-cool-application/terraform\n[INFO]  Config: /Volumes/Secured/user/git/your-cool-application/terraform/config.tf\n[INFO]  Environment:    /Volumes/Secured/user/git/your-cool-application/terraform/environment.tf\n[WARNING]  Environment file 'environment.tf' exists and will be overridden\n[INFO]  Looking in '/Volumes/Secured/user/git/your-cool-application/terraform/./'\n[INFO]  Looking in '/Volumes/Secured/user/git/your-cool-application/terraform/../'\n[INFO]  Looking in '/Volumes/Secured/user/git/your-cool-application/terraform/../../'\n[INFO]  Found 'aws-terraform-modules' in '/Volumes/Secured/user/git/your-cool-application/terraform/../../'\n[INFO]  Module source will be: '../../aws-terraform-modules/environment/dev/config'\n\nAfter this operation configuration will be changed\nDo you want to continue? [Y/n] y\n[INFO]  Environment successfully switched: dev\n\n$ cat environment.tf\n######################################\n##   DO NOT EDIT THIS FILE          ##\n##   Generated by tfconfig          ##\n######################################\n\nmodule \"config\" {\n  source = \"../../aws-terraform-modules/environment/dev/config\"\n}\n```\n\n### dotenv\n\nGenerate `.env` file or expose configuration into env vars from AWS Parameter Store via your provided `.env.\u003cenvironment\u003e`\n\nBefore start to working with `dotenv` command you should have `AWS_REGION` environment variable!\n\nInspiring by [ssm-env](https://github.com/remind101/ssm-env) I've got part of @remind101 code that communicates with AWS.\n\n#### dotenv examples\n\n```\n$ export AWS_REGION=us-west-1\n$ tfconfig dotenv example\nDOTENV_SECURE_DB_HOST=db1.example.com DOTENV_PLAIN_DB_NAME=db_name DOTENV_SECURE_DB_PASSWORD=PaSsW0rd\n$ tfconfig dotenv example -e\nexport DOTENV_PLAIN_DB_NAME=db_name\nexport DOTENV_SECURE_DB_PASSWORD=PaSsW0rd\nexport DOTENV_SECURE_DB_HOST=db1.example.com\n$ tfconfig dotenv example .env\n[INFO]  Path:   /Volumes/Secured/user/git/tfconfig/src\n[INFO]  Environment:    example\n[INFO]  Source dotEnv file:     .env.example\n[INFO]  Destination dotEnv file:        .env\n[WARNING]  dotEnv file '.env' exists and will be overridden\n\nAfter this operation configuration will be changed\nDo you want to continue? [Y/n] y\n[INFO]  Successful.\n$ env $(tfconfig dotenv example) node -e \"console.log(process.env)\" | grep \"DOTENV_\"\n  DOTENV_SECURE_DB_PASSWORD: 'PaSsW0rd',\n  DOTENV_SECURE_DB_HOST: 'db1.example.com',\n  DOTENV_PLAIN_DB_NAME: 'db_name' }\n$ eval \"$(tfconfig dotenv example -e)\"\n$ env | grep \"DOTENV_\"\nDOTENV_SECURE_DB_HOST=db1.example.com\nDOTENV_SECURE_DB_PASSWORD=PaSsW0rd\nDOTENV_PLAIN_DB_NAME=db_name\n```\n\nSome different use case, might be useful:\n1. Reading `.env.example`, getting values from AWS SSM and writes into `.env.dev`\n2. Reading `.env.dev` and then exposing vars without requesting those from AWS SSM, because a new `.env.dev` doesnt have values that should be requested\n\n```\n$ tfconfig dotenv example .env.dev -c\n[INFO]  Path:   /Volumes/Secured/user/git/tfconfig/src\n[INFO]  Environment:    example\n[INFO]  Source dotEnv file:     .env.example\n[INFO]  Destination dotEnv file:        .env.dev\n[WARNING]  Confirmation has been skipped via running environment configuration\n[INFO]  Successful.\n$ cat .env.dev\nDOTENV_PLAIN_DB_NAME=\"db_name\"\nDOTENV_SECURE_DB_HOST=\"db1.example.com\"\nDOTENV_SECURE_DB_PASSWORD=\"PaSsW0rd\"\n$ tfconfig dotenv dev -e\nexport DOTENV_PLAIN_DB_NAME=db_name\nexport DOTENV_SECURE_DB_HOST=db1.example.com\nexport DOTENV_SECURE_DB_PASSWORD=PaSsW0rd\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobondar%2Ftfconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwobondar%2Ftfconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobondar%2Ftfconfig/lists"}