{"id":26636040,"url":"https://github.com/phsaurav/terrasample","last_synced_at":"2025-07-26T21:07:08.717Z","repository":{"id":284032806,"uuid":"921216556","full_name":"phsaurav/terrasample","owner":"phsaurav","description":"A multi-layred production ready terraform backend infra architecture sample","archived":false,"fork":false,"pushed_at":"2025-03-23T18:50:43.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T19:35:34.913Z","etag":null,"topics":["production-ready","terraform","terraform-aws","terraform-module","terraform-workspace"],"latest_commit_sha":null,"homepage":"https://medium.com/aws-tip/managing-multiple-shadow-cloud-architectures-across-development-staging-and-production-17ff55390828","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phsaurav.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":"2025-01-23T15:02:00.000Z","updated_at":"2025-03-23T18:53:53.000Z","dependencies_parsed_at":"2025-03-23T19:46:27.405Z","dependency_job_id":null,"html_url":"https://github.com/phsaurav/terrasample","commit_stats":null,"previous_names":["phsaurav/terraform-backend-infra"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phsaurav%2Fterrasample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phsaurav%2Fterrasample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phsaurav%2Fterrasample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phsaurav%2Fterrasample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phsaurav","download_url":"https://codeload.github.com/phsaurav/terrasample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304872,"owners_count":20593626,"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":["production-ready","terraform","terraform-aws","terraform-module","terraform-workspace"],"created_at":"2025-03-24T16:16:47.287Z","updated_at":"2025-07-26T21:07:08.700Z","avatar_url":"https://github.com/phsaurav.png","language":"HCL","readme":"\n# TerraSample\n\nTerraSample is a generic portfolio project demonstrating a modular approach to infrastructure management using Terraform. This project serves as a template for showcasing best practices and standard module organization for a two tier cloud infrastructure.\n\n![image](https://github.com/user-attachments/assets/ede43305-7678-4aa8-bd35-250ab8e4a12a)\n\n\n## Project Structure\n```\n.\n├── README.md\n├── main.tf\n├── variables.tf\n├── outputs.tf\n├── modules/\n│   ├── moduleA/\n│   │   ├── README.md\n│   │   ├── variables.tf\n│   │   ├── main.tf\n│   │   ├── outputs.tf\n│   ├── moduleB/\n│   └── ...\n```\n\n## Getting Started\n\n### Prerequisites\n\n### Setup AWS Credentials:\nAs a prerequisite first, we have to set AWS credentials for both our development and production AWS accounts \nIAM configuration to `~/.aws/credentials`(For Mac) consisting of proper IAM permissions. For temporary credentials also \nadd the session key.\n```\n[dev]\naws_access_key_id = \u003cACCESS_KEY\u003e\naws_secret_access_key = \u003cSECRET_KEY\u003e\n\n[prod]\naws_access_key_id = \u003cACCESS_KEY\u003e\naws_secret_access_key = \u003cSECRET_KEY\u003e\naws_session_token= \u003cSESSION_TOKEN\u003e\n```\n\n### Remote Backend \u0026 Variables\n1.Backend Infra setup for example for s3+dynamodb:\n`backend.tf`\n```tf\nterraform {\n  backend \"s3\" {\n    bucket         = \"\u003cbackend-infra-bucket-name\u003e\"\n    encrypt        = true\n    key            = \"path/terraform.tfstate\"\n    region         = \"\u003cregion\u003e\"\n    dynamodb_table = \"\u003cbackend-infra-lock-dynamodb-table-name\u003e\"\n  }\n}\n```\n\n2. Key value .tfvars configuration file example with sensetive data:\n`dev.tfvars`\n```tfvars\n# Generic variables\nproject     = \"terrasample\"\naws_region  = \"\u003cregion\u003e\"\nprofile     = \"terrasample-dev\"\nenvironment = \"dev\"\n```\n\n### Initialize the Project\n\n```bash\nterraform init\n```\n\n### Basic Terraform Commands\n\n## Basic Terraform Commands\n\n### Changing Environment in Terraform:\n\nSelect development environment:\n\n```bash\nterraform workspace select dev\n```\n\nSelect production environment:\n\n```bash\nterraform workspace select prod\n```\n\n#### Plan:\n\n```bash\n# For Development Environment\nterraform workspace select dev \u0026\u0026 terraform plan -var-file=\"dev.tfvars\"\n# For Production Environment\nterraform workspace select dev \u0026\u0026 terraform plan -var-file=\"prod.tfvars\"\n```\n\n#### Apply:\n\n```bash\n# For Development Environment\nterraform workspace select dev \u0026\u0026 terraform apply -var-file=\"dev.tfvars\"\n# For Production Environment\nterraform workspace select dev \u0026\u0026 terraform apply -var-file=\"prod.tfvars\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphsaurav%2Fterrasample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphsaurav%2Fterrasample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphsaurav%2Fterrasample/lists"}