{"id":13575379,"url":"https://github.com/SebastianUA/terraform","last_synced_at":"2025-04-04T22:31:03.727Z","repository":{"id":28770992,"uuid":"118637305","full_name":"SebastianUA/terraform","owner":"SebastianUA","description":"The place to storing Terraform modules of many providers","archived":false,"fork":false,"pushed_at":"2025-01-28T12:08:11.000Z","size":10491,"stargazers_count":197,"open_issues_count":1,"forks_count":106,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T12:11:36.493Z","etag":null,"topics":["argocd","aws","azure","cloudflare","consul","gcp","helm","heroku","jfrog","kubernetes","local","newrelic","null-resource","oci","pfptmeta","random","terraform","terraform-modules","tls","vault"],"latest_commit_sha":null,"homepage":"","language":"HCL","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/SebastianUA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"vitalii_natarov"}},"created_at":"2018-01-23T16:29:26.000Z","updated_at":"2025-01-21T03:45:55.000Z","dependencies_parsed_at":"2023-10-03T14:45:34.465Z","dependency_job_id":"347ce638-c90b-4fa6-9f51-607f1564f176","html_url":"https://github.com/SebastianUA/terraform","commit_stats":{"total_commits":394,"total_committers":6,"mean_commits":65.66666666666667,"dds":0.3350253807106599,"last_synced_commit":"cef181c89722963bb127a871f284bb23443abaf9"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianUA%2Fterraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianUA%2Fterraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianUA%2Fterraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebastianUA%2Fterraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SebastianUA","download_url":"https://codeload.github.com/SebastianUA/terraform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247006663,"owners_count":20868033,"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":["argocd","aws","azure","cloudflare","consul","gcp","helm","heroku","jfrog","kubernetes","local","newrelic","null-resource","oci","pfptmeta","random","terraform","terraform-modules","tls","vault"],"created_at":"2024-08-01T15:01:00.451Z","updated_at":"2025-04-04T22:30:58.716Z","avatar_url":"https://github.com/SebastianUA.png","language":"HCL","funding_links":["https://ko-fi.com/vitalii_natarov"],"categories":["HCL"],"sub_categories":[],"readme":"# Terraform usage\n----------------\n![terraform-lint](https://github.com/SebastianUA/terraform/workflows/terraform-lint/badge.svg) ![](https://img.shields.io/github/last-commit/sebastianua/terraform.svg) ![](https://img.shields.io/github/repo-size/sebastianua/terraform.svg)  ![LatestVer](https://img.shields.io/github/release/sebastianua/terraform.svg) ![License](https://img.shields.io/badge/License-GPLv3-blue.svg)\n\n## Install Terraform\n\n- If you're using MacOS, then you can run the next command to install TF:\n```bash\n$ brew install terraform\n```\nNOTE: you must install `HOMEBREW` to your host something like:\n```bash\n$ sudo /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\n```\n- For Unix/Linux OS you might go to the official Terraform site and download bin-file with software.\n\n## Init\n\n---------\nFirst of all, you should clone this repo to your local machine. I provided modules with simple examples. After, go to needed example and run the next command:\n```bash\n$ terraform init\n```\n\nThis command will init everything to provision module(s).\n\n\n## Plan\n---------\nWhen you set `terraform init` you will be able to see which services are going to create with the next command:\n\n```bash\n$ terraform plan\n```\n\nIf you're using `tfvars`, you can run the following command:\n\n```bash\n$ terraform plan -var-file terraform.tfvars\n```\n\nIt's a good point to use `tfvars` for multiple environments, - as example.\n\n## Apply\n---------\nTo apply your stack, you can use:\n\n```bash\n$ terraform apply\n```\n\nOr:\n\n```bash\n$ terraform apply -var-file terraform.tfvars\n```\n\nAlso, you can use `-auto-approve` command to automatically apply the stack.\n\n## Destroy\n---------\nTo terminate the stack, use:\n\n```bash\n$ terraform destroy\n```\n\nOr:\n\n```bash\n $ terraform destroy -var-file terraform.tfvars\n```\n\nAlso, you can use `-auto-approve` command to automatically terminate the stack.\n\n## graph\n\nIf you're using mac OS, you must install the next package:\n```bash\n$ brew install graphviz\n```\n\nThen, run:\n```bash\n$ terraform graph | dot -Tsvg \u003e graph.svg\n\n$ terraform graph | dot -Tpng \u003e graph.png\n```\n\n## state\n\nIf you would like to remove your stack from TF statefile, you can use this command:\n\n```bash\n$ terraform state rm \"module.rds_single_mysql.aws_db_subnet_group.db_subnet_group[0]\"\n```\n\nThe structura is the next one: `module.\u003cMODULE_NAME\u003e.\u003cRESOURCE_NAME\u003e.\u003cNAME_of_RESOURCE\u003e[count.index]`.\n\nWhere:\n\n- MODULE_NAME - The module name.\n- RESOURCE_NAME - the resource name of provider.\n- NAME_of_RESOURCE - The name of resource of created RESOURCE_NAME.\n- [count.index] - Index of resource in loop.\n\nThat's it.\n\n## import\n\nIf you would like to import some stack stack to TF, you can use this command:\n\n```bash\n$ terraform import --var 'db_password=PW_HERE' \"module.rds_single_mysql.aws_db_subnet_group.db_subnet_group[0]\" \"terraform-20220711082550455200000001\"\n```\n\nThe structura is the next one: `module.\u003cMODULE_NAME\u003e.\u003cRESOURCE_NAME\u003e.\u003cNAME_of_RESOURCE\u003e[count.index] \u003cIMPORTING_VALUE\u003e ` .\n\nWhere:\n\n- MODULE_NAME - The module name.\n- RESOURCE_NAME - the resource name of provider.\n- NAME_of_RESOURCE - The name of resource of created RESOURCE_NAME.\n- [count.index] - Index of resource in loop.\n- IMPORTING_VALUE - The value to import.\n\nThat's it.\n\n## Help\n\n---------\n\nTo get help, use:\n\n```bash\n$ terraform -help\nUsage: terraform [global options] \u003csubcommand\u003e [args]\n\nThe available commands for execution are listed below.\nThe primary workflow commands are given first, followed by\nless common or more advanced commands.\n\nMain commands:\n  init          Prepare your working directory for other commands\n  validate      Check whether the configuration is valid\n  plan          Show changes required by the current configuration\n  apply         Create or update infrastructure\n  destroy       Destroy previously-created infrastructure\n\nAll other commands:\n  console       Try Terraform expressions at an interactive command prompt\n  fmt           Reformat your configuration in the standard style\n  force-unlock  Release a stuck lock on the current workspace\n  get           Install or upgrade remote Terraform modules\n  graph         Generate a Graphviz graph of the steps in an operation\n  import        Associate existing infrastructure with a Terraform resource\n  login         Obtain and save credentials for a remote host\n  logout        Remove locally-stored credentials for a remote host\n  output        Show output values from your root module\n  providers     Show the providers required for this configuration\n  refresh       Update the state to match remote systems\n  show          Show the current state or a saved plan\n  state         Advanced state management\n  taint         Mark a resource instance as not fully functional\n  test          Experimental support for module integration testing\n  untaint       Remove the 'tainted' state from a resource instance\n  version       Show the current Terraform version\n  workspace     Workspace management\n\nGlobal options (use these before the subcommand, if any):\n  -chdir=DIR    Switch to a different working directory before executing the\n                given subcommand.\n  -help         Show this help output, or the help for a specified subcommand.\n  -version      An alias for the \"version\" subcommand.\n```\n\n## Auto-switching Terraform version\n\n---------\n\nThe `tfswitch` command line tool lets you switch between different versions of [terraform](https://www.terraform.io/). If you do not have a particular version of terraform installed, `tfswitch` lets you download the version you desire. The installation is minimal and easy. Once installed, simply select the version you require from the dropdown and start using terraform.\n\nTo install this tool for macOS:\n\n```bash\n$ brew install warrensbox/tap/tfswitch\n```\n\nLinux:\n\n```bash\n $ curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash\n```\n\nSnapcraft for CentOS, Ubuntu, Linux Mint, RHEL, Debian, Fedora:\n\n```bash\n$ sudo snap install tfswitch\n```\n\n**Automatically switch with bash**\n\nAdd the following to the end of your `~/.bashrc` file: (Use either `.tfswitchrc` or `.tfswitch.toml` or `.terraform-version`):\n\n```bash\ncdtfswitch(){\n  builtin cd \"$@\";\n  cdir=$PWD;\n  if [ -e \"$cdir/.tfswitchrc\" ]; then\n    tfswitch\n  fi\n}\nalias cd='cdtfswitch'\n```\n\n**Automatically switch with zsh**\n\nAdd the following to the end of your `~/.zshrc` file:\n\n```bash\nload-tfswitch() {\n  local tfswitchrc_path=\".tfswitchrc\"\n\n  if [ -f \"$tfswitchrc_path\" ]; then\n    tfswitch\n  fi\n}\nadd-zsh-hook chpwd load-tfswitch\nload-tfswitch\n```\n\nTo get list of the supported version of the software, run the next command:\n\n```bash\n$ tfswitch -l\n```\n\nOr:\n\n ```bash\n$ tfswitch --list-all\n ```\n\nScroll up or down to see versions. Click on needed to use it.\n\nIf a `*.tf` file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to the lastest version:\n\n```bash\nterraform {\n  required_version = \"\u003e= 0.13.9\"\n\n  required_providers {\n    aws        = \"\u003e= 2.52.0\"\n    kubernetes = \"\u003e= 1.11.1\"\n  }\n}\n```\n\nI really like this tool and it can be used for your locally run as well as for CI/CD.\n\n## Module Sources\n\nThe source argument in a module block tells Terraform where to find the source code for the desired child module.\n\nTerraform uses this during the module installation step of terraform init to download the source code to a directory on local disk so that it can be used by other Terraform commands.\n\n### Local Paths\nLocal path references allow for factoring out portions of a configuration within a single source repository:\n```\nmodule \"vpc\" {\n  source = \"../aws/modules/vpc\"\n}\n```\n\nA local path must begin with either ./ or ../ to indicate that a local path is intended, to distinguish from a module registry address.\n\nLocal paths are special in that they are not \"installed\" in the same sense that other sources are: the files are already present on local disk (possibly as a result of installing a parent module) and so can just be used directly. Their source code is automatically updated if the parent module is upgraded.\n\n### Terraform Registry\nA module registry is the native way of distributing Terraform modules for use across multiple configurations, using a Terraform-specific protocol that has full support for module versioning.\n\nTerraform Registry is an index of modules shared publicly using this protocol. This public registry is the easiest way to get started with Terraform and find modules created by others in the community:\n```\nmodule \"consul\" {\n  source = \"hashicorp/consul/aws\"\n  version = \"0.1.0\"\n}\n```\n\n### GitHub\n\nTerraform will recognize unprefixed github.com URLs and interpret them automatically as Git repository sources:\n```\nmodule \"consul\" {\n  source = \"github.com/hashicorp/example\"\n}\n```\n\nOr:\n```\nmodule \"ram\" {\n  source = \"git@github.com:SebastianUA/terraform.git//aws/modules/ram?ref=dev\"\n}\n```\nArbitrary Git repositories can be used by prefixing the address with the special git:: prefix. After this prefix, any valid Git URL can be specified to select one of the protocols supported by Git.\n\nFor example, to use HTTPS or SSH:\n```\nmodule \"vpc\" {\n  source = \"git::https://example.com/vpc.git\"\n}\n\nmodule \"storage\" {\n  source = \"git::ssh://username@example.com/storage.git\"\n}\n```\n\n### Fetching archives over HTTP\nAs a special case, if Terraform detects that the URL has a common file extension associated with an archive file format then it will bypass the special terraform-get=1 redirection described above and instead just use the contents of the referenced archive as the module source code:\n```\nmodule \"vpc\" {\n  source = \"https://example.com/vpc-module.zip\"\n}\n```\n\n### S3 Bucket\nYou can use archives stored in S3 as module sources using the special s3:: prefix, followed by an S3 bucket object URL:\n```\nmodule \"consul\" {\n  source = \"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip\"\n}\n```\n\nAnd others.\n\n## Using Terraform for multiple AWS accounts\n\nYou can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis. The primary reason for this is to support multiple regions for a cloud platform; other examples include targeting multiple Docker hosts, multiple Consul hosts, etc.\n\nTo create multiple configurations for a given provider, include multiple provider blocks with the same provider name. For each additional non-default configuration, use the alias meta-argument to provide an extra name segment. For example:\n```\n#\n# MAINTAINER Vitaliy Natarov \"vitaliy.natarov@yahoo.com\"\n#\nterraform {\n  required_version = \"~\u003e 0.13\"\n}\n\n# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n# Account from resoure will be shared (owner)\n# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nprovider \"aws\" {\n  region                  = \"us-east-1\"\n  shared_credentials_file = pathexpand(\"~/.aws/credentials\")\n  profile                 = \"owner\"\n\n  alias = \"owner\"\n}\n\nmodule \"ram_owner\" {\n  source      = \"git@github.com:SebastianUA/terraform.git//aws/modules/ram?ref=dev\"\n  name        = \"tmp\"\n  environment = \"dev\"\n\n  providers = {\n    aws = aws.owner\n  }\n\n  # RAM resource share\n  enable_ram_resource_share                    = true\n  ram_resource_share_name                      = \"test-ram-shared-resource-1\"\n  ram_resource_share_allow_external_principals = true\n\n  # RAM resource association\n  enable_ram_resource_association       = true\n  ram_resource_association_resource_arn = \"arn:aws:ec2:YOUR_REGION_HERE:YOUR_AWSID_HERE:transit-gateway/tgw-095a7bb025f42d2b0\"\n\n  tags = map(\"Env\", \"stage\", \"Orchestration\", \"Terraform\")\n}\n\n# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n# Account to resoure will be shared (main)\n# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nprovider \"aws\" {\n  region                  = \"us-east-1\"\n  shared_credentials_file = pathexpand(\"~/.aws/credentials\")\n  profile                 = \"main\"\n}\n\nmodule \"ram_main_accepter\" {\n  source      = \"git@github.com:SebastianUA/terraform.git//aws/modules/ram?ref=dev\"\n  name        = \"tmp\"\n  environment = \"dev\"\n\n  # RAM principal association\n  enable_ram_principal_association             = true\n  ram_principal_association_resource_share_arn = module.ram_owner.ram_resource_share_id\n  ram_principal_association_principal          = data.aws_caller_identity.current.account_id\n\n  # RAM resource share accepter\n  enable_ram_resource_share_accepter    = true\n  ram_resource_share_accepter_share_arn = module.ram_owner.ram_principal_association_id\n\n  depends_on = [\n    module.ram_owner\n  ]\n}\n```\nThe official documentation is https://www.terraform.io/docs/language/providers/configuration.html#provider-versions.\n\n\n\n## Cloud cost estimates for Terraform\n\nInfracost shows cloud cost estimates for infrastructure-as-code projects such as Terraform. It helps developers, devops and others to quickly see a cost breakdown and compare different options upfront.\n\n## Installation\n\n1. Assuming [Terraform](https://www.terraform.io/downloads.html) is already installed, get the latest Infracost release:\n\n   macOS Homebrew:\n\n   ```\n   brew install infracost\n   ```\n\n   Linux/macOS manual download:\n\n   ```\n   os=$(uname | tr '[:upper:]' '[:lower:]') \u0026\u0026 \\\n   arch=$(uname -m | tr '[:upper:]' '[:lower:]' | sed -e s/x86_64/amd64/) \u0026\u0026 \\\n   curl -s -L https://github.com/infracost/infracost/releases/latest/download/infracost-$os-$arch.tar.gz | tar xz -C /tmp \u0026\u0026 \\\n   sudo mv /tmp/infracost-$os-$arch /usr/local/bin/infracost\n   ```\n\n   Docker and Windows users see [here](https://www.infracost.io/docs/#installation).\n\n2. Register for a free API key:\n\n   ```\n   infracost register\n   ```\n\n   The key is saved in `~/.config/infracost/credentials.yml`.\n\n3. Run Infracost using our example Terraform project to see how it works:\n\n   ```\n   git clone https://github.com/infracost/example-terraform.git\n   cd example-terraform\n   \n   # Play with sample1/main.tf and re-run to compare costs\n   infracost breakdown --path sample1\n   \n   # Show diff of monthly costs, edit the yaml file and re-run to compare costs\n   infracost diff --path sample1 --usage-file sample1/infracost-usage.yml\n   ```\n\nPlease **watch/star** this repo as we add new cloud resources every week or so.\n\n## Usage\n\nThe `infracost` CLI has the following main commands, their usage is described in our short [**getting started**](https://www.infracost.io/docs/#usage) page:\n\n- `breakdown`: show full breakdown of costs\n- `diff`: show diff of monthly costs between current and planned state\n\nAs mentioned in our [FAQ](https://www.infracost.io/docs/faq), **no** cloud credentials, secrets, tags or resource identifiers are sent to the Cloud Pricing API. That API does not become aware of your cloud spend; it simply returns cloud prices to the CLI so calculations can be done on your machine. Infracost does not make any changes to your Terraform state or cloud resources.\n\n## CI/CD integrations\n\nThe following CI/CD integrations can be used to automatically add a pull request comment showing the diff of monthly costs between the current and planned state:\n\n- [GitHub Action](https://www.infracost.io/docs/integrations/cicd#github-action)\n- [GitLab CI template](https://www.infracost.io/docs/integrations/cicd#gitlab-ci)\n- [CircleCI Orb](https://www.infracost.io/docs/integrations/cicd#circleci)\n- [Bitbucket Pipeline](https://www.infracost.io/docs/integrations/cicd#bitbucket-pipelines)\n- [Atlantis](https://www.infracost.io/docs/integrations/cicd#atlantis)\n\nIf you run into any issues with CI/CD integrations, please join our [community Slack channel](https://www.infracost.io/community-chat), we'd be happy to guide you through it. The GitHub page is https://github.com/infracost/infracost.\n\n## Auto-generate documentation for Terraform modules\n\n---------\n\nI have a python script to generate the `README.md` file-based on Terraform modules and examples that I'm supporting. The code can be found here:  [generate-tf-docs](https://github.com/SebastianUA/generate-tf-docs).\n\n## Authors\n\nCreated and maintained by [Vitaliy Natarov](https://github.com/SebastianUA). An email: [vitaliy.natarov@yahoo.com](vitaliy.natarov@yahoo.com).\n\n## License\nApache 2 Licensed. See [LICENSE](https://github.com/SebastianUA/terraform/blob/master/LICENSE) for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSebastianUA%2Fterraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSebastianUA%2Fterraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSebastianUA%2Fterraform/lists"}