Giter Site home page Giter Site logo

aws-infra-terraform's Introduction

aws-infra-terraform

This project is used to standardize and deploy the core infrastructure components in AWS across multiple regions using terraform. The goal is to programmatically deploy and manage multiple environments (production, development, staging, etc) across any number of regions from a central location while maintaining isolation between environments and regions within Terraform.

Architecture

AWS Infra Topology

Environment Region CIDR Block
Production US-West-2 10.0.0.0/14
Production US-East-1 10.4.0.0/14
Development US-West-2 172.16.0.0/14
Development US-East-1 172.20.0.0/14

Setup

AWS Credentials

AWS credentials are assumed to be passed in from your local aws credentials file using profiles for each environment. profile variables are set in the enviroment provider file.

Terraform Workspaces

Create a workspaces for each region within the environment (production, development, staging, etc) you plan to deploy and work within. This is how isolation is achieved between regions and environments.

Navigate to the environment you want to work with then initialize terraform and then create a workspace for each region.

Here we are creating two workspaces us-east-1 and us-west-2 in the production environment.

cd environments/production
terraform init
terraform workspace new us-east-1
terraform workspace new us-west-2

You will be automatically dropped into the workspace once it is created. Listing the workspaces now should look like this:

terraform workspace list         
  default
  us-east-1
* us-west-2

Usage

Navigate to the environment you want to work with if you are not already there from the step above. Then select the workspace of the region you want to deploy and work within

cd environments/production 
terraform workspace select us-west-2

Bastion Host Access

An AWS key-pair is created using the public key provided in the environment variable TF_VAR_pub_key The security group created uses the environment variable TF_VAR_bastion_admins

export TF_VAR_pub_key='<your pub key here>'
export TF_VAR_bastion_admins=['public_ip1', 'public_ip2']

Deploy

When ready plan and apply changes for each region. Dont forget to switch workspaces when working with a different region

terraform plan -var-file=us-west-2.tfvars
terraform apply -var-file=us-west-2.tfvars

terraform workspace select us-east-1
terraform plan -var-file=us-east-1.tfvars
terraform apply -var-file=us-east-1.tfvars

Repeat these steps for additional environment.

Credit for terraform organization and workspace setup goes here: https://dev.to/sdileep/manage-a-multi-environment-multi-region-infrastructure-on-aws-using-terraform-1p2p

aws-infra-terraform's People

Contributors

that1guy15 avatar

Watchers

 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.