“Building an AWS complete infrastructure with terraform and ansible”

Bhusan
2 min readSep 11, 2019

--

A guide to create scalable AWS environment with help of terraform and ansible along with deploying wordpress site.Few things to be considered before starting e.g:sound knowledge on aws ,linux,terraform.

Preview:

AWS infrastructure diagram
Architecture of AWS environment to be deployed

Resources:

  1. Route 53 hosted zones -2(private,public)
  2. VPC -1
  3. Availability Zones -2
  4. Subnets -7(2 ELB,2 ASG,3RDS)
  5. Route Tables -2(1Public,1 Private)
  6. Security Groups -4(1RDS,1 ASG,1 Dev instance,1 ELB)
  7. VPC S3 Endpoint
  8. Internet Gateway
  9. S3 Code Bucket

Process Flow:

Flow of terraform and ansible files on building Instance
Flow of Terraform and Ansible files on building AWS infrastructure

Deployment Steps:

  1. Update version / Install Python on your local machine.

#apt install python-pip

2. Download and install terraform.

#curl -O https://releases.hashicorp.com/terraform/0.11.2/terraform_0.11.2_linux_amd64.zip

3. Install AWS Cli

#pip install awscli — upgrade

4. Add repo of Ansible and install ansible

#apt-add-repository ppa:ansible/ansible

#apt-get install ansible

5. ssh-keygen setup

6. AWS User setup

Go to AWS console,select IAM>add user>select access type- programmatic access>permission>attach existing policies already>select Administration>click review>click create user

Download the .csv file.

7. Domain set up.

Go to AWS console>Route53>Register domain

or

If you have already a domain or want to buy from outside ,then go to hosted zone and create a record set.

8. Create Delegation Set

On local machine,

#aws route53 create-reusable-delegation-set — caller-reference

Make a note of above output and copy name servers, go to aws console>registered domain/hosted zones,select the domain

Add or edit name server>paste the copied name servers.

9. Please go through below git link and copy the terraform and ansible codes for deployment.

https://github.com/bhusanlab/TERRAWS

Good Luck

Bhusan

www.linkedin.com/in/bhusanmex

--

--