DEPLOYING WORDPRESS AND MYSQL ON AWS WITH CUSTOM VPC USING TERRAFORM





What is Amazon VPC?

Amazon Virtual Private Cloud is a commercial cloud computing service that provides users a virtual private cloud, by “provisioning a logically isolated section of Amazon Web Services Cloud”.


Wordpress

WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database.


Pre-requisites:-

  1. AWS account

  2. AWS CLI installed and configured

  3. Terraform installed and added to path

  4. VSCode with HashiCorp Terraform and Terraform Autocomplete plugins installed


Process:-

1. First we need to create the provider. Our provider is AWS therefore, we select AWS with other relevant information like the credentials.

provider "aws" {
region                  = "ap-south-1"
shared_credentials_file = "C:/Users/KIIT/.aws/credentials"
profile                 = "chirag"
}

2. Next we shall create the key pairs which shall be used to remotely login to the instances.

resource "tls_private_key" "keypair" {
algorithm   = "RSA"
}
resource "local_file" "privatekey" {
content     = tls_private_key.keypair.private_key_pem
filename = "key1.pem"
}
resource "aws_key_pair" "deployer" {
key_name   = "key1.pem"
public_key = tls_private_key.keypair.public_key_openssh
}