Giter VIP home page Giter VIP logo

terraform-aws-demo's Introduction

Terraform AWS Demo

This git repository contains infrastructure as code (terraform) to deploy a common architecture to AWS. It creates a public and private network, a bastion host to connect to your private instances and an expample application behind a loadbalancer. Additionally it creates resources to manage your terraform state remotly.

Overview

What we will build: aws-diagram

Prerequisites

  • Terraform installed on machine
  • AWS account

Usage

I devided this project in 3 parts:

  1. create resources for statemanagement
  2. create resources for the base infrastructure
  3. create resources for an example application

In my demo AWS access_key and secret_key will be automatically loaded from ~/.aws/credentials since i have set that up previously.

1. Initialize for Remote Management of terraform state and state lock

Folder: 01-state-management

This folder contains files to create following ressources:

  • S3 Bucket for storing the terraform state files
  • DynamoDB for managing locks of terraform state files

Commands:

cd 01-state-management
terraform init
terraform plan
terraform apply
tf_state_region=$(terraform output -raw region)
tf_state_bucket=$(terraform output -raw s3_bucket)
tf_state_dynamodb_table=$(terraform output -raw dynamodb)

2. Creating infrastructure in AWS

Folder: 02-base-infrastructure

After initialization of the remote state management this folder contains files to create following resources:

  • VPC
  • 3 private networks (1 for each availability zone in given region)
  • 3 public networks (1 for each az as well)
  • Internet Gateway
  • Nat Gateway in each zone
  • Resilient Bastion Host in an autoscaling group
  • (Optional) A dns zone
cd 02-base-infrastructure
terraform init \
    -backend-config="bucket=$tf_state_bucket" \
    -backend-config="key=terraform-aws-demo.tfstate" \
    -backend-config="region=$tf_state_region" \
    -backend-config="dynamodb_table=$tf_state_dynamodb_table"
terraform plan
terraform apply

3. Create example app in AWS

Folder: 03-example-app

This creates 3 ec2 instances and a loadbalancer as an example. Optionally a DNS record can be created as well.

cd 03-example-app
terraform init \
    -backend-config="bucket=$tf_state_bucket" \
    -backend-config="key=terraform-aws-demo-app.tfstate" \
    -backend-config="region=$tf_state_region" \
    -backend-config="dynamodb_table=$tf_state_dynamodb_table"
terraform plan
terraform apply

terraform-aws-demo's People

Watchers

Klaus Aye avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.