############################################################
Sample Infra to create WordPress in AWS
############################################################
-
terraform init
-
terraform plan
-
terraform apply
We have to make sure Python, AWS cli, Ansible, Terraform all 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>
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
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
1. sudo yum install ansible
2. ansible --version </br>
ansible 2.4.2.0
-
[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> -
terraformuser@dockervm ~]$ sudo ssh-agent bash
-
[root@dockervm terraformuser]# ssh-add /root/.ssh/prakashssh
Identity added: /root/.ssh/prakashssh (/root/.ssh/prakashssh)
- user name terraformuser
- attach Administrator Policy
- create user
- make sure a domain name exists
- root@dockervm prakash-ansible]# aws configure --profile awsprakash
- [root@dockervm prakash-ansible]# aws configure --profile awsprakash
- AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxx
- AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxx
- Default region name [None]: us-west-2
- Default output format [None]: txt
- [root@dockervm prakash-ansible]#
- [root@dockervm prakash-ansible]# aws ec2 describe-instances --profile awsprakash
- 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
put the above name servers there
also go to hosted zones and put the same name servers
define the terraform variables </br>
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
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
a) Disable selinux on all instances while provisioning b) install aws cli on all instances as it will not come as default in RedHat