In order to use it Terraform v0.13.5 (not tested in other versions) will be needed
In order to have it deployed:
$ git clone https://github.com/JASG94/AWS_PiHole.git
$ cd AWS_PiHole
$ terraform init
To continue, an AWS account created with SSH Keys and configured in our laptop is required. Also AWS credentials should be configured.
The deployment could be customized by the following variables in variables.tf file:
variable "instance_type" {
description = "EC2 instance type"
type = string
default = "t2.micro"
}
variable "key_name" {
description = "SSH Key AWS name"
type = string
default = "awskey"
}
variable "ssh_key" {
description = "SSH Key directory path"
type = string
default = "/home/javi/ssh_keys/aws.pem"
}
Recommendable to change PiHole admin password which can be found in /files/docker-compose.yml as WEBPASSWORD
Once configured, to proceed with the deployment:
$ terraform apply --autoaprove
This will create:
- A new Security Group allowing only SSH, HTTP and DNS incoming traffic
- An EC2 instanci with docker and docker-compose installed and runing pi-hole.
The output will tell us the public IPv4 of our EC2 instance where we can find PiHole running.