{"id":18292511,"url":"https://github.com/marclop/terraform-playground","last_synced_at":"2025-04-09T07:55:25.183Z","repository":{"id":36144674,"uuid":"40448682","full_name":"marclop/terraform-playground","owner":"marclop","description":null,"archived":false,"fork":false,"pushed_at":"2015-08-09T20:24:14.000Z","size":120,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T02:19:09.259Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/marclop.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":"2015-08-09T20:00:10.000Z","updated_at":"2017-02-02T16:55:14.000Z","dependencies_parsed_at":"2022-09-05T18:30:10.438Z","dependency_job_id":null,"html_url":"https://github.com/marclop/terraform-playground","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/marclop%2Fterraform-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Fterraform-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Fterraform-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Fterraform-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marclop","download_url":"https://codeload.github.com/marclop/terraform-playground/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999852,"owners_count":21031044,"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":[],"created_at":"2024-11-05T14:18:22.809Z","updated_at":"2025-04-09T07:55:25.161Z","avatar_url":"https://github.com/marclop.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform\n\nThis repo contains terraform command inside a docker container with Consul as a storage backend for Terraform.\n\n## Requirements\n\n* docker\n* docker-compose\n* dig\n* curl\n\n## Environment settings\n\nDepending on which platform you run docker, you might need to adjust the variable `DOCKER_ENGINE_HOST` to point to your docker engine host (used for the script to query the consul nodes).\n\nSimply set those variables in the terminal, and the script `terraform.bash` will automatically respond to the settings (just remember to re-`source terraform.bash` every time you set a new value for those variables)\n\n```\n$ DOCKER_ENGINE_HOST=\"localhost\"\n```\n\nYou can also tune how many consul nodes will be spawned with the variable `CONSUL_NODES`\n```\n$ CONSUL_NODES=3\n```\n\n## Usage\n\n### Terraform\n\n#### Initialization\n\n```\n$ source terraform.bash\n$ pre_run\n$ terraform_config\n  Remote configuration updated\n  Remote state configured and pulled.\n```\n\n### Vault\n\n#### Initialization\n\nInitialization using Consul as a storage backend and using the root key to create basic vault configs\n\n```\n$ vault init\n  Key 1: c8b4a1ec3482c296e6604a4810157df395f9f3d654c54b03631c764c1428dab301\n  Key 2: 2cd87bd50bf63621a357fba9b894506a4aa18ac8b036fa9ab0b6baa14a505d2a02\n  Key 3: 6075c93f0ab4ba2ca6f9ca475b7190f85d8883227c9f2be075c6ac91e676d4e903\n  Key 4: 0fb69fcbb952494250b2c5b50bdabfa7bcbe8923529413f8a02b3a1fb5fa53f504\n  Key 5: 431b2d21b810c54f551cf45be83f7f35ab9780c99e3dc282655b2c2f19dcda3605\n  Initial Root Token: bac0e5f0-69b4-3925-1156-64129cbbea74\n  [..]\n$ vault unseal c8b4a1ec3482c296e6604a4810157df395f9f3d654c54b03631c764c1428dab301\n  Sealed: true\n  Key Shares: 5\n  Key Threshold: 3\n  Unseal Progress: 1\n$ vault unseal 2cd87bd50bf63621a357fba9b894506a4aa18ac8b036fa9ab0b6baa14a505d2a02\n  Sealed: true\n  Key Shares: 5\n  Key Threshold: 3\n  Unseal Progress: 2\n$ vault unseal 6075c93f0ab4ba2ca6f9ca475b7190f85d8883227c9f2be075c6ac91e676d4e903\n  Sealed: false\n  Key Shares: 5\n  Key Threshold: 3\n  Unseal Progress: 0\n$ vault auth bac0e5f0-69b4-3925-1156-64129cbbea74\n  Successfully authenticated! The policies that are associated\n  with this token are listed below:\n\n  root\n$ vault mount consul\n  Successfully mounted 'consul' at 'consul'!\n```\n\n#### Policy creation\n\n```\n$ vault policy-write dev /vault/dev.hcl\n  Policy 'dev' written.\n$ vault policy-write dev-rw vault/dev-rw.hcl\n  Policy 'dev-rw' written.\n```\n\n#### Token with policy attached\n\n```\n$ vault token-create -policy=dev\n  cf3f90d0-6d32-2e8e-f8f7-790d8ba1c3dd\n$ vault token-create -policy=dev-rw\n  63ed72e0-4e32-7d3c-5153-79ddfbb1f1c6\n```\n\n#### Write/read generic secrets\n\n```\n$ vault write secret/dev/secret1 username=myuser password=mypassword lease=1h\n  Success! Data written to: secret/dev/secret1\n$ vault read -format=json secret/dev/secret1\n{\n\t\"lease_id\": \"secret/dev/secret1/688f2da0-ebc7-35a5-c925-3d273325887d\",\n\t\"lease_duration\": 3600,\n\t\"renewable\": false,\n\t\"data\": {\n    \"lease\": \"1h\",\n\t\t\"password\": \"mypassword\",\n\t\t\"username\": \"myuser\"\n\t}\n}\n```\n\n### Consul\n\n#### Register vault service with health check\n\n```\n$ register_service vault\n  Status: 200\n  {\n    \"ID\": \"vault\",\n    \"Name\": \"vault\",\n    \"Tags\": [\n      \"vault\",\n    ],\n    \"Address\": \"172.17.0.18\",\n    \"Port\": 8200,\n    \"Check\": {\n      \"Name\": \"Vault health check\",\n      \"http\": \"http://172.17.0.18:8200/v1/sys/health\",\n      \"Notes\": \"HTTP based health check\",\n      \"Interval\": \"10s\",\n      \"Timeout\": \"2s\"\n    }\n  }\n```\n\n## Links\n\n* [Consul UI](http://localhost:8500/ui)\n* [Consul API](http://localhost:8500/v1)\n* [Vault API](http://localhost:8200/v1)\n\n## Cleanup\n\n```\n$ terraform_cleanup\nKilling terraform_consulSlave_2...\nKilling terraform_consulSlave_1...\nKilling terraform_vault_1...\nKilling terraform_consul_1...\nGoing to remove terraform_vault_1, terraform_consulSlave_2, terraform_consulSlave_1, terraform_consul_1\nRemoving terraform_consul_1...\nRemoving terraform_vault_1...\nRemoving terraform_consulSlave_2...\nRemoving terraform_consulSlave_1...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarclop%2Fterraform-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarclop%2Fterraform-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarclop%2Fterraform-playground/lists"}