{"id":18522457,"url":"https://github.com/pdrastil/demo-terraform-aws","last_synced_at":"2026-05-10T03:43:45.007Z","repository":{"id":46814658,"uuid":"244764054","full_name":"pdrastil/demo-terraform-aws","owner":"pdrastil","description":"Demo for AWS immutable infrastructure","archived":false,"fork":false,"pushed_at":"2023-01-24T23:26:32.000Z","size":37,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T05:28:18.920Z","etag":null,"topics":["ansible","aws","packer","terraform"],"latest_commit_sha":null,"homepage":null,"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/pdrastil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-03T23:33:28.000Z","updated_at":"2021-04-22T10:31:29.000Z","dependencies_parsed_at":"2023-02-14T02:31:12.926Z","dependency_job_id":null,"html_url":"https://github.com/pdrastil/demo-terraform-aws","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/pdrastil%2Fdemo-terraform-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-terraform-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-terraform-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-terraform-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdrastil","download_url":"https://codeload.github.com/pdrastil/demo-terraform-aws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198512,"owners_count":22030966,"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":["ansible","aws","packer","terraform"],"created_at":"2024-11-06T17:31:10.969Z","updated_at":"2026-05-10T03:43:44.956Z","avatar_url":"https://github.com/pdrastil.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform demo for AWS\n\nThis repository contains sample deployment of infrastructure to\nAWS with Terraform and Packer.\n\n## Goal\n\nProject goal is to create highly available infrastructure in AWS that is using classic EC2 instances as a servers for web application.\n\n### What gets deployed\n\n- AWS VPC with default CIDR 10.0.0.0/16\n- Public and private subnets in 2 availability zones\n- AMI image with web application\n- Elastic load balancer for public subnets\n- Autoscaling group with web application in private zone\n- Security groups to allow public access only to load balancer\n\n### Gotchas\n\nDemo implementation is not entirely immutable. This is caused by integration of Packer into terraform scripts via `null_resource` provider. When you do this AMI search gets dependent on Packer and will be invalidated for any consequent run of terraform which causes replacement of every resource that consumes such AMI. This behavior was kept for sake of simplicity and to allow you do the teardown of whole environment without leaving anything behind.\n\nIf you would like to modify this for production it's recommended to have special network where your automation tooling lives and where you can perform AMI build independently before invoking terraform. Then you will just trigger another job with desired image ID that should be used by terraform.\n\n## Setup\n\nPlease refer to next sections what should be installed and configured to make this demo work.\n\n### Software\n\n- [Ansible] via `pip install ansible`\n- [AWS CLI] via `pip install awscli`\n- [Terraform]\n- [Packer]\n\n### Amazon Web Services\n\nTo test the deployment you will need to have AWS account. In the account activate subscription for [CentOS 7] image that is used as base image for Packer build. Also create user account with Administrator privileges and programatic access. Then run `aws configure` and enter your access key and secret key for this user account.\n\nIf you already use AWS and have account with Administrator privileges, then this demo expects that such account is a default one. If you need to assume role or have such account in different profile it's recommended to use tool such as [aws-vault] to inject\nyour environment with valid credentials prior the deployment.\n\n### Private keys for EC2 instances\n\nTo create EC2 instances you need create SSH key pair used for authentication. Run `ssh-keygen` to generate new key pair and create override in `terraform.tfvars` or modify default value in [variables.tf](./variables.tf) to provide valid\npath to your public key.\n\n## Usage\n\nTo deploy AWS environment with Terraform run following:\n\n```sh\n$ terraform init\n$ terraform plan\n$ terraform apply\n```\n\n[Ansible]: \u003chttps://ansible.com/\u003e\n[AWS CLI]: \u003chttps://aws.amazon.com/cli/\u003e\n[Packer]: \u003chttps://packer.io/\u003e\n[Terraform]: \u003chttps://terraform.io/\u003e\n[CentOS 7]: \u003chttps://aws.amazon.com/marketplace/pp/B00O7WM7QW/\u003e\n[aws-vault]: \u003chttps://github.com/99designs/aws-vault\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdrastil%2Fdemo-terraform-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdrastil%2Fdemo-terraform-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdrastil%2Fdemo-terraform-aws/lists"}