hardselius / AWS-terraform-examples

Playing with Terraform to deploy AWS instances

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Version

Playing with Terraform to deploy AWS instances

Quick start

Note: These examples deploy resources into your AWS account. Although all the resources should fall under the AWS Free Tier, it is not my responsibility if you are charged money for this.

  1. Install Terraform.
  2. Set your AWS credentials as the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  3. cd into one of the example folders.
  4. Run terraform init.
  5. Run terraform apply.
  6. After it's done deploying, the example will output URLs or IPs you can try out.
  7. To clean up and delete all resources after you're done, run terraform destroy.

Examples

  1. single-web-server: Deploy a single EC2 Instance with a web server that will return "Hello, World" for every request on port 8080.
  2. cluster-of-web-servers: Deploy a cluster of EC2 Instances in an Auto Scaling Group (ASG) and an Elastic Load Balancer (ELB). The ELB listens on port 80 and distributes load across the EC2 Instances, each of which runs the same "Hello, World" web server.
  3. s3-backend: Create an S3 bucket and DynamoDB table to use as a Terraform backend.
  4. database: Deploy MySQL on top of Amazon's Relational Database Service (RDS).
  5. modules: Examples of reusable Terraform modules, including a module that can deploy a web server cluster on top of ASG with an ELB.
  6. live: Examples of how to deploy different live environments (i.e., staging, production) using the code from the modules folder.
  7. loops-with-count: Examples of how to use the count parameters to "loop" over resources.
  8. loops-with-for-each: Examples of how to use for_each to "loop" over inline blocks.
  9. loops-with-for: Examples of how to use for to "loop" over individual values.
  10. gaming-on-aws-with-terraform: Setup a gaming Windows machine on EC2

Production

production: Here is the the setup I've used for my demo site at borsoi.co.uk

To do:

  • auto-install VPN server and output keys
  • open VPN and SSH ports
  • auto-install HTTPS certificates and apache
  • point elastic IP to load balancer

About

Playing with Terraform to deploy AWS instances


Languages

Language:HCL 86.1%Language:Smarty 13.5%Language:Shell 0.4%