CloudFormation template to create an EC2 Instance running Ubuntu Server 20.04 with Pi-Hole. Note that some regions do not include t3.micro in the Free Tier. Do a double check! I do not assume any responsability for unexpected charges!!! The template will not allow you to choose something different than t2.micro or t3.micro to limit any unwanted costs. Modify this constraint if you need more perfomance, e.g. small, medium instances.
- An AWS account
- A KeyPair
- AWS CLI (optional but preferred)
You need to know your public IP and pre-existing KeyPair, e.g. your-keypair.pem.
The following commands assume you have configured AWS CLI properly by setting up your profile, i.e. aws configure
.
On Unix/Linux systems:
export MYIP=`curl https://ifconfig.co`
aws --profile yourprofile cloudformation \
create-stack --stack-name ph-ec2 \
--template-body file://path/to/ph-ec2.yaml \
--parameters ParameterKey=KeyName,ParameterValue=your-key-pair-name \
ParameterKey=ClientIP,ParameterValue=$MYIP/32 \
ParameterKey=InstanceType,ParameterValue=t3.micro \
--disable-rollback \
--capabilities CAPABILITY_NAMED_IAM
Import the stack as explained here and follow the steps in the wizard.
aws --profile yourprofile cloudformation \
describe-stacks --stack-name ph-ec2 \
--query "Stacks[0].Outputs[?OutputKey=='PublicIP'].OutputValue" --output text
ssh -i "your-keypair.pem" ubuntu@instance-public-ip
Now you can set the Web Interface password.
aws --profile yourprofile cloudformation \
delete-stack --stack-name ph-ec2
Just select it and click "Delete".
- IPv6 support
- Automatic creation/deletion of the stack at certain times