How to set up WordPress with a dedicated Database Server on AWS Cloud?

What is WordPress?

Project Description

aws configure
resource "aws_vpc" "ananya_vpc" {
cidr_block = "192.168.0.0/16"
instance_tenancy = "default"
enable_dns_hostnames = true
tags = {
Name = "ananya_vpc"
}
}
resource "aws_subnet" "ananya_public_subnet" {
vpc_id = "${aws_vpc.ananya_vpc.id}"
cidr_block = "192.168.0.0/24"
availability_zone = "ap-south-1a"
map_public_ip_on_launch = "true"
tags = {
Name = "ananya_public_subnet"
}
}



resource "aws_subnet" "ananya_private_subnet" {
vpc_id = "${aws_vpc.ananya_vpc.id}"
cidr_block = "192.168.1.0/24"
availability_zone = "ap-south-1a"
tags = {
Name = "ananya_private_subnet"
}
}
resource "aws_internet_gateway" "ananya_gw" {
vpc_id = "${aws_vpc.ananya_vpc.id}"
tags = {
Name = "ananya_gw"
}
}
resource "aws_route_table" "ananya_rt" {
vpc_id = "${aws_vpc.ananya_vpc.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.ananya_gw.id}"
}
tags = {
Name = "ananya_rt"
}
}
resource "aws_route_table_association" "ananya_rta" {
subnet_id = "${aws_subnet.ananya_public_subnet.id}"
route_table_id = "${aws_route_table.ananya_rt.id}"
}
resource "aws_security_group" "ananya_sg" {name        = "ananya_sg"
vpc_id = "${aws_vpc.ananya_vpc.id}"
ingress {

description = "allow_http"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = [ "0.0.0.0/0"]
}ingress {

description = "allow_ssh"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {

description = "allow_icmp"

from_port = 0
to_port = 0
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {

description = "allow_mysql"
from_port = 3306

to_port = 3306
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}


tags = {
Name = "ananya_sg"
}
}
resource "aws_security_group" "ananya_sg_private" {name        = "ananya_sg_private"
vpc_id = "${aws_vpc.ananya_vpc.id}"

ingress {

description = "allow_mysql"
from_port = 3306
to_port = 3306
protocol = "tcp"
security_groups = [aws_security_group.ananya_sg.id]

}
ingress {

description = "allow_icmp"
from_port = -1
to_port = -1
protocol = "icmp"
security_groups = [aws_security_group.ananya_sg.id]

}
egress {

from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}


tags = {
Name = "ananya_sg_private"
}
}
resource "aws_instance" "wordpress" {

ami = "ami-ff82f990"
instance_type = "t2.micro"
key_name = "ananya_key"
subnet_id = "${aws_subnet.ananya_public_subnet.id}"
security_groups = ["${aws_security_group.ananya_sg.id}"]
associate_public_ip_address = true
availability_zone = "ap-south-1a"
tags = {
Name = "ananya_wordpress"
}
}
resource "aws_instance" "sql" {
ami = "ami-08706cb5f68222d09"
instance_type = "t2.micro"
key_name = "ananya_key"
subnet_id = "${aws_subnet.ananya_private_subnet.id}"
availability_zone = "ap-south-1a"
security_groups = ["${aws_security_group.ananya_sg_private.id}"]

tags = {
Name = "ananya_sql"
}
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Agile Development. Down the trend?

Create Online Courses Fast for Free with OBS!

Create Online Courses Fast for Free with OBS!

Zigging and Zagging the enemies.

The Best Countries for Developers to Work in

TryHackMe — Advent of Cyber 2 — Day 5

Road TO Dev — Create a start mechanic

Introducing The New Microsoft Edge

Lessons from starting and shutting down a ‘startup’ within Atlassian

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ananya Sharma

Ananya Sharma

More from Medium

Hosting Website on S3 + Cloudfront Distribution

Hosting a Static Website with AWS S3

How to create a static website hosted on S3

Load Time Example of Static Website Served Through CloudFront