{"id":16118998,"url":"https://github.com/germainlefebvre4/terraform-cheatsheet","last_synced_at":"2025-04-14T12:22:43.365Z","repository":{"id":80782740,"uuid":"141931590","full_name":"germainlefebvre4/terraform-cheatsheet","owner":"germainlefebvre4","description":"A usefull cheatsheet for Terraform usage.","archived":false,"fork":false,"pushed_at":"2018-10-26T06:51:11.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T01:44:14.179Z","etag":null,"topics":["hcf","terraform"],"latest_commit_sha":null,"homepage":"","language":null,"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/germainlefebvre4.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-22T21:21:09.000Z","updated_at":"2020-03-04T21:49:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8d0fa45-889d-4eed-99c9-90496a2c8c1a","html_url":"https://github.com/germainlefebvre4/terraform-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/germainlefebvre4%2Fterraform-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/germainlefebvre4%2Fterraform-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/germainlefebvre4%2Fterraform-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/germainlefebvre4%2Fterraform-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/germainlefebvre4","download_url":"https://codeload.github.com/germainlefebvre4/terraform-cheatsheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248878449,"owners_count":21176333,"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":["hcf","terraform"],"created_at":"2024-10-09T20:52:00.727Z","updated_at":"2025-04-14T12:22:43.331Z","avatar_url":"https://github.com/germainlefebvre4.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform CheatSheet\nA usefull cheatsheet for Terraform usage.\nWritten by Germain LEFEBVRE by August 2018 from Terraform v0.11.7.\n\n**Table of Contents**\n1. [Context](#context)\n1. [Terraform Commands](#terraform-commands)\n1. [Terraform configuration management](#terraform-configuration-management)\n   1. [Global variables](#global-variables)\n   1. [Environment management](#environment-management)\n   1. [Requiring variables](#requiring-variables)\n   1. [Environments variables](#eenvironments-variables)\n\n## Context\n\nSee version of Terraform with `terraform --version` :\n```\nTerraform v0.11.7\n```\n\n## Terraform commands\n\nThe first step to know is all your structure will be store in a `main.tf` file in your current directory.\n\n\nThese are the main Terraform commands.\n\nShow Terraform help.\n\n`terraform --help`\n\n```\nUsage: terraform [--version] [--help] \u003ccommand\u003e [args]\n```\n\n\nInitiliaze your Terraform directory (1st step needed with new directory).\n`terraform init`\n\n\nValidate your Terraform files, coherence in structure but no syntax checking.\n\n`terraform validate`\n\n\nSee what Terraform will change but not applying any change.\n\n`terraform plan`\n\n\nApply modifications on your infrastructure.\n\n`terraform apply`\n\n\nRemove all your modifications (made with apply).\n`terraform destroy`\n\n\n## Terraform configuration management\n\n### Global variables\nWith the art of calling all your resources from a `main.tf` file you will have a another files containing all your variables.\nThe file name does not matter while your call it with the `.tf` extension. Whatever the way your name it, variables.tf or vars.tf, it will be call while it remains in the same directory of your `main.tf` file.\n```\n./\n +-- main.tf\n +-- vars.tf\n```\n\n### Environment management\nTake care to your configuration files if your want to manage different environments becasue it will change regarding the way your wnat to handle it.\n\nI have a particular preference for managing config files with files but no workspace because everything is files in Linux.\nTo do so you will pay attention to seprate every environments in different files (dev, sit, qa, prod, ...).\n\n#### Requiring variables\nThe main thing to know is you need a global variables file to specify your required variables. As requiring vars file I mean the Global variables files described just above.\n\n#### Environments variables\nAfter describing requiring variables you can play in creating structure by environment (directories) and setup a file with your environment vars. The name of this file does not matter in a chaos way. But if you want to make automation I suggest you to name the env files exactly the same in all your env directories.\n\nConsidering your resource file named `main.tf`and your global vars file name `variables.tf` you wil have a file structure like this :\n```\n./\n+-- dev/\n    +-- vars.tf\n+-- prod/\n    +-- vars.tf\n+-- main.tf\n+-- variables.tf\n```\n\nLike this files `main.tf` and `variables.tf` wil be called at every `terraform` run. You will just need to specify your environment file with the parameter `-var-file=\u003cyou_file\u003e` :\n\n`terraform plan -var-file=./dev/vars.tf`\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgermainlefebvre4%2Fterraform-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgermainlefebvre4%2Fterraform-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgermainlefebvre4%2Fterraform-cheatsheet/lists"}