Skip to content

opschronicle/wordpress-test

Repository files navigation

############################################################

wordpress-test

Sample Infra to create WordPress in AWS

############################################################

Run the following commands to create infra

  • terraform init

  • terraform plan

  • terraform apply

We have to make sure Python, AWS cli, Ansible, Terraform all installed

Make sure pip is installed

1. [terraformuser@dockervm ~]$ sudo python --version </br>
     Python 2.7.5

2. subscription-manager repos --enable rhel-server-rhscl-7-rpms </br>
3. scl enable python27 bash  </br>

4. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py </br>

5. path-to-specific-python-binary/python get-pip.py </br>

6. pip install --upgrade pip </br>

Install terraform

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

 2. sudo unzip terraform_0.11.2_linux_amd64.zip -d /bin/terraform/
 3. export PATH=$PATH:/bin/terraform

Install AWSCLI

 1. sudo pip install awscli --upgrade

 2. aws --version  </br>
       aws-cli/1.16.107 Python/2.7.5 Linux/3.10.0-862.el7.x86_64 botocore/1.12.97

Install Ansible

 1. sudo yum install ansible
 2. ansible --version  </br>
       ansible 2.4.2.0

set up keys

  1. [terraformuser@dockervm ~]$ sudo ssh-keygen

    [sudo] password for terraformuser:
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/prakashssh </.br>

        Created directory '/root/.ssh'.  </br>
           Enter passphrase (empty for no passphrase): </br>
           Enter same passphrase again: </br>
    
  2. terraformuser@dockervm ~]$ sudo ssh-agent bash

  3. [root@dockervm terraformuser]# ssh-add /root/.ssh/prakashssh
    Identity added: /root/.ssh/prakashssh (/root/.ssh/prakashssh)

Create IAM user in AWS console

  1. user name terraformuser
  2. attach Administrator Policy
  3. create user

Download the access keys

Go to Route53

  • make sure a domain name exists

set up the access key id

  1. root@dockervm prakash-ansible]# aws configure --profile awsprakash
  2. [root@dockervm prakash-ansible]# aws configure --profile awsprakash
  3. AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxx
  4. AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxx
  5. Default region name [None]: us-west-2
  6. Default output format [None]: txt
  7. [root@dockervm prakash-ansible]#
  8. [root@dockervm prakash-ansible]# aws ec2 describe-instances --profile awsprakash

create reusable delegation set

  1. aws route53 create-reusable-delegation-set --caller-reference 1224 --profile awsprakash

https://route53.amazonaws.com/2013-04-01/delegationset/xxxxxxxxxxxx
DELEGATIONSET 1224 /delegationset/xxxxxxxxxxxxxx
NAMESERVERS ns-663.awsdns-18.net
NAMESERVERS ns-1751.awsdns-26.co.uk
NAMESERVERS ns-101.awsdns-12.com
NAMESERVERS ns-1034.awsdns-01.org

now go to AWS console click your domain ansd add/edit name servers

put the above name servers there
also go to hosted zones and put the same name servers

create all the terraform files

define the terraform variables </br>

terraform init

terraform plan

This will just display green empty bits, this shows all is working

now add all the terraform bits in main.tf
and try terraform plan

now add VOC code
add router code
etc..
etc..

finally format the code

terraform fmt --diff

to find AWS redhat image id

try seraching in AWS public images with query
"Owner: 309956199498"

also make sure to put a single line inside userdata file

[root@dockervm prakash-ansible]# ssh-agent bash
[root@dockervm prakash-ansible]# ssh-add /root/.ssh/prakashssh

As we are using RedHat linux make sure to add the following

a) Disable selinux on all instances while provisioning b) install aws cli on all instances as it will not come as default in RedHat

About

Sample Infra to create WordPress in AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors