Skip to content

Commit 44206f7

Browse files
committed
Adding wordpress module
0 parents  commit 44206f7

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-0
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
.terraform.*
8+
9+
# Crash log files
10+
crash.log
11+
12+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
13+
# .tfvars files are managed as part of configuration and so should be included in
14+
# version control.
15+
#
16+
# example.tfvars
17+
18+
# Ignore override files as they are usually used to override resources locally and so
19+
# are not checked in
20+
override.tf
21+
override.tf.json
22+
*_override.tf
23+
*_override.tf.json
24+
25+
# Include override files you do wish to add to version control using negated pattern
26+
#
27+
# !example_override.tf
28+
29+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
30+
# example: *tfplan*

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Wordpress Terraform module
2+
3+
Terraform module which creates RDS instance,ec2, associated vpc and install Wordpress.
4+
5+
### Module Usage
6+
```
7+
module "wordpress" {
8+
source = "github.com/tecbrix/aws-wordpress"
9+
name = "wordpress"
10+
env = "test"
11+
}
12+
```

files/userdata.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
sudo apt-get install -y \
3+
apt-transport-https \
4+
ca-certificates \
5+
curl \
6+
software-properties-common
7+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
8+
sudo apt-key fingerprint 0EBFCD88
9+
sudo add-apt-repository \
10+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
11+
$(lsb_release -cs) \
12+
stable"
13+
sudo apt-get update
14+
sudo apt-get install -y docker-ce
15+
sudo docker run hello-world
16+
# Linux post-install
17+
sudo groupadd docker
18+
sudo usermod -aG docker $USER
19+
sudo systemctl enable docker
20+
sudo mkdir -p /var/www/html
21+
sudo echo "testing ${WORDPRESS_DB_HOST}" >> /var/log/test
22+
sudo docker run -e WORDPRESS_DB_USER="${WORDPRESS_DB_USER}" -e WORDPRESS_DB_NAME="${WORDPRESS_DB_NAME}" -e WORDPRESS_DB_PASSWORD="${WORDPRESS_DB_PASSWORD}" -e WORDPRESS_DB_HOST="${WORDPRESS_DB_HOST}" --name wordpress -p 80:80 -v "$PWD/html":/var/www/html -d wordpress

main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module "vpc" {
2+
source = "github.com/tecbrix/aws-vpc"
3+
#tag
4+
name = "wordpress"
5+
env = "test"
6+
}
7+
8+
module "rds" {
9+
depends_on = [
10+
module.vpc
11+
]
12+
source = "github.com/tecbrix/aws-rds"
13+
mysql_sec_id = module.vpc.mysql_sec_id
14+
password = "Rds#admin=55"
15+
#tag
16+
name = "wordpress"
17+
env = "test"
18+
}
19+
20+
module "ec2" {
21+
depends_on = [
22+
module.rds
23+
]
24+
source = "github.com/tecbrix/aws-ec2"
25+
userdata = "files/userdata.sh"
26+
subnet_id = module.vpc.pub_subnet_for_ec2
27+
web_sec_id = module.vpc.web_sec_id
28+
db_pwd = "Rds#admin=55"
29+
db_name = module.rds.rdsdb
30+
db_user = module.rds.rdsuser
31+
db_host = module.rds.rdshost
32+
#tag
33+
name = "wordpress"
34+
env = "test"
35+
}

output.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
output "ec2_pub_ip" {
2+
description = "Public Ip of ec2"
3+
value = module.ec2.ec2_pub_ip
4+
}
5+
6+
output "ec2_pub_dns" {
7+
description = "Public DNS of ec2"
8+
value = module.ec2.ec2_pub_dns_name
9+
}
10+
11+
output "wordpress_url" {
12+
description = "wordpress url is"
13+
value = "Wordpress url is http://${module.ec2.ec2_pub_dns_name}"
14+
}
15+
# output "ec2_pub_prvt_name" {
16+
# description = "Private DNS of ec2"
17+
# value = module.ec2.private_dns
18+
# }

provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = var.region
3+
}

var.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "region" {
2+
default = "eu-west-1"
3+
}

0 commit comments

Comments
 (0)